-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheaps.h
33 lines (25 loc) · 1.03 KB
/
heaps.h
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
33
#ifndef C_INTERPRETER_HEAPS_H
#define C_INTERPRETER_HEAPS_H
//-----------------------------------------------------
//------------------------ A Struct Containing Variable
typedef struct variable
{
char* name;
float value;
} variable;
//-----------------------------------------------------
//----------------------- Swapping Node With Its Parent
void siftUP(variable hp[], int i);
//-----------------------------------------------------
//---------------------------- Sifting Up Every Element
void heapifyUp(variable *hp,unsigned long n);
//-----------------------------------------------------
//---------------------------------------- Heapify Down
void heapifyDown(variable *hp,int n);
//-----------------------------------------------------
//-------------------------------------- Sorts The Heap
void heapSort(unsigned long n,variable arr[]);
//-----------------------------------------------------
//------------------------------------ Prints The Array
void printArray(variable *arr,unsigned long n);
#endif //C_INTERPRETER_HEAPS_H