-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheap_test.cpp
More file actions
50 lines (38 loc) · 1.11 KB
/
heap_test.cpp
File metadata and controls
50 lines (38 loc) · 1.11 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//============================================================================
// Name : cs4511.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <cstdlib>
#include "Heap.h"
using namespace std;
int main(int args, char** argv) {
cout << "start Heap Test" << endl;
int i = 1;
MinHeap<Node<int> > minHeap;
MaxHeap<Node<int> > maxHeap;
srand ( time(NULL) );
while (i < 10) {
cout << "step " << i << endl;
int* in = new int(rand()%100);
Node<int>* n = new Node<int>(in);
cout << "made node" << endl;
maxHeap.addNode(n);
cout << "added to maxHeap" << endl;
minHeap.addNode(n);
cout << "added to minHeap" << endl;
//heap.print();
i++;
}
cout << "final MinHeap:" << endl;
minHeap.print();
cout << "Min Value: " << *(minHeap.getMin()->getValue()) << endl;
cout << "final MaxHeap:" << endl;
maxHeap.print();
cout << "Max Value: " << *(maxHeap.getMax()->getValue()) << endl;
cout << "done" << endl;
return 0;
}