-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
56 lines (51 loc) · 1.03 KB
/
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
//
// main.cpp
// binary heap.
//
// Created by alifar on 10/27/16.
// Copyright © 2016 alifar. All rights reserved.
//
#include "binary_heap.hpp"
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main(int argc, const char *argv[]){
cout << "Binary Heap implementation." << endl;
bool heap_type = false; // true if Heap is MaxHeap
char input;
cout << "Type of Heap? [default: MinHeap, 1 for MaxHeap]: ";
if(cin.get() != '\n'){
heap_type = true;
}
cout << endl;
BinaryHeap<int> heap;
heap.max_heap = heap_type;
cout << "Insert items into Heap: ";
int item;
do{
cin >> item;
heap.Insert(item);
} while(cin.get() != '\n');
cout << "Heap: ";
for(auto it: heap){
cout << it << " ";
}
cout << endl;
cout << "Removing Root." << endl;
heap.RemoveRoot();
cout << "Heap: ";
for(auto it: heap){
cout << it << " ";
}
cout << endl;
cout << "Enter an index to remove: ";
int index;
cin >> index;
heap.RemoveAt(index);
cout << "Heap: ";
for(auto it: heap){
cout << it << " ";
}
cout << endl;
}