-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeap.cpp
70 lines (57 loc) · 1.02 KB
/
Heap.cpp
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include"minHeap.h"
using namespace std;
int main()
{
minHeap<int> H1;
//cout<<(-1/2)<<endl;
H1.Push(1);
H1.Push(8);
H1.Push(4);
H1.Push(0);
H1.Push(-1);
H1.Push(10);
H1.Push(11);
H1.Push(19);
H1.Push(2);
H1.Push(5);
//H1.Print();
while(!H1.isEmpty())
{
cout<<H1.Top()<<" ";
H1.Pop();
}
cout<<endl;
int arr[10] = {1,8,4,0,-1,10,11,19,2,5};
minHeap<int> H2(arr,10);
//H.Print();
while(!H2.isEmpty())
{
cout<<H2.Top()<<" ";
H2.Pop();
}
int arr2[5] = {1,4,5,3,1};
minHeap<int> H3(arr2,5);
// cout<<H.Top()<<endl;
// H.Print();
// H.Pop();
// H.Print();
// cout<<H.Top()<<endl;
// cout<<endl;
while(!H3.isEmpty())
{
cout<<H3.Top()<<" ";
H3.Pop();
}
minHeap<int> H4;
H4.Push(1);
H4.Push(4);
H4.Push(5);
H4.Push(3);
H4.Push(1);
while(!H4.isEmpty())
{
cout<<H4.Top()<<" ";
H4.Pop();
}
return 0;
}