-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtkd_queue.h
More file actions
32 lines (29 loc) · 1.33 KB
/
tkd_queue.h
File metadata and controls
32 lines (29 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef TKDQUEUE_H
#define TKDQUEUE_H
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* name: perculateUp
* author: Weida Pan
* description: update upwards in a heap
* implementation: find swap the largest among current node and its children to current index, do recursively
* arguments: int a[] -- keys of heap
* int index[] -- index of heap
* int pos -- current index in heap
* return value: none
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
void perculateUp(int a[], int index[], int pos);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* name: popqueue
* author: Weida Pan
* description: pop the head from a heap and maintain the property of heap
* implementation: put an key to the head, and update downwards by find the largest among current position and its children
* execute recursively until hit the tail of heap
* arguments: int a[] -- index of heap
* int v[] -- keys of heap
* return value: index of the formar head key
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int popqueue(int a[],int v[]);
#endif