Implement a minimum (min) heap of integers, and write a driver to demonstrate its functionality. Min heaps work the same way as maximum (max) heaps except the a parent is always smaller than its children.
The class your min heap should have the following methods
insert: Add a new element to the heap, and bubble up as needed. delete: Remove the first element from the heap and then reheapify. heapSort: Make a copy of the heap, then remove and print each element from the clone. Make sure this doesn’t modify the current heap. print: Prints the elements in the heap in breadth order.
Example Print Out:
Int Min Heap Tester
Populating Heap with values
21
37
49
11
23
1
13
16
33
17
Printing Heap
1
16
11
21
17
49
13
37
33
23
Testing heap sort
1 11 13 16 17 21 23 33 37 49
Removing an element from the heap
The element removed is 1 and the heap now is:
11
16
13
21
17
49
23
37
33
Lab Report Questions:
1. Demonstrate each step of inserting the elements 21, 37, 49, 11, 23, 1, 13, 16, 33, and 17 into this min heap.
2. Demonstrate each step of inserting the same elements in a max heap.
3. Show each step when deleting two elements from the min heap.