Question: Please provide the entire program (a) Write a method replaceKey in the MinHeap class with the following signature: public void replaceKey (Integer oldKey, Integer newKey)
Please provide the entire program

(a) Write a method replaceKey in the MinHeap class with the following signature: public void replaceKey (Integer oldKey, Integer newKey) The method will replace the first occurrence of oldKey with the newKey, and restore the Min-Heap property after the change. If the oldKey does not exist in the heap, the method prints an appropriate message and returns without changing the heap. Example: Suppose our binary heap object (bh) has the following keys: ***4 6732 19 64 26 99 42 5428 Then the method call: bh.replaceKey (oldKey Integer(54), newKey Integer(2)) should change the keys to: ***2 4732 6 64 26 99 42 1928 Note: You can assume that the methods perlocateUp and perlocateDown are already implemented in your MinHeap class. (b) What is the running time complexity of your replaceKey method? Justify
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
