28 int parent(
int i) {
return (i - 1) / 2; }
31 int left(
int i) {
return (2 * i + 1); }
34 int right(
int i) {
return (2 * i + 2); }
57 std::cout <<
"\nOverflow: Could not insertKey\n";
67 while (i != 0 &&
harr[parent(i)] >
harr[i]) {
78 while (i != 0 &&
harr[parent(i)] >
harr[i]) {
137 std::cout <<
h.extractMin() <<
" ";
138 std::cout <<
h.getMin() <<
" ";
140 std::cout <<
h.getMin();
int * harr
pointer to array of elements in heap
int capacity
maximum possible size of min heap
void decreaseKey(int i, int new_val)
int heap_size
Current number of elements in min heap.