TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
binaryheap.cpp File Reference

A C++ program to demonstrate common Binary Heap Operations. More...

#include <climits>
#include <iostream>
#include <utility>
Include dependency graph for binaryheap.cpp:

Go to the source code of this file.

Classes

class  MinHeap
 

Functions

int main ()
 

Detailed Description

A C++ program to demonstrate common Binary Heap Operations.

Definition in file binaryheap.cpp.

Function Documentation

◆ main()

int main ( void )

Definition at line 128 of file binaryheap.cpp.

128 {
129 MinHeap h(11);
130 h.insertKey(3);
131 h.insertKey(2);
132 h.deleteKey(1);
133 h.insertKey(15);
134 h.insertKey(5);
135 h.insertKey(4);
136 h.insertKey(45);
137 std::cout << h.extractMin() << " ";
138 std::cout << h.getMin() << " ";
139 h.decreaseKey(2, 1);
140 std::cout << h.getMin();
141 return 0;
142}
int h(int key)