Question
Write a program to implement the min heap. Your insert method will insert the value in the correct place and display the vale of parent
Write a program to implement the min heap. Your insert method will insert the value in the correct place and display the vale of parent node, value of left child and value of right child. The remove method will remove the root and display its value which is the min value.
Test your program on the following:
minHeap.insert(5);
minHeap.insert(3);
minHeap.insert(17);
minHeap.insert(10);
minHeap.insert(84);
minHeap.insert(19);
minHeap.insert(6);
minHeap.insert(22);
minHeap.insert(9);
minHeap.remove());
Remember that: In a Min Binary Heap, the key at root must be minimum among all keys present in Binary Heap.
Need answer in Java Class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started