-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
63 lines (39 loc) · 963 Bytes
/
main.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
/*
* File: main.cpp
* Author: kurt
*
* Created on July 15, 2014, 12:10 PM
*/
#include <cstdlib>
#include <iostream>
#include <cmath>
#include "heap.h"
using namespace std;
int height(int size)
{
int log = std::log2(size);
return log + 1;
}
int main(int argc, char** argv)
{
min_heap<double> h; // TODO: try min_heap<double> h
for (auto i = 10; i < 120; i += 10) {
double dble = static_cast<double>(i);
dble -= 5;
int priority = i;
h.add(priority, dble);
cout << "\n\nPrinting heap";
h.print_heap(cout);
}
cout << "\n";
cout << h;
cout << endl;
double d;
while (!h.isEmpty()) {
d = h.peekTop();
cout << "\nThe top of the heap was: " << d << endl;
h.remove();
cout << "Heap is: " << h << endl;
}
return 0;
}