Menu
info@onlinenursinghomework.com
Cell: +1 (714) 584-4466

How to Write (in Java) a method replaceKey in the MaxHeap class with the following signature:

How to Write (in Java) a method replaceKey in the MaxHeap 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 Max-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: 

Don't use plagiarized sources. Get Your Custom Essay on
How to Write (in Java) a method replaceKey in the MaxHeap class with the following signature:
Just from $9/Page or 300 words
Order Now

*** 99 64 42 54 32 28 6 19 7 26 4 

Then the method call: bh.replaceKey (new Integer(54), new Integer(105) should change the keys to: 

*** 105 99 42 64 32 28 6 19 7 26 4 

Note: You can assume that the methods perlocateUp and perlocateDown are already implemented in your MaxHeap class. 

Only the code is needed, not a full Java program

Looking for a similar assignment? Get help from our nursing qualified experts!

Order Now

Open chat
Get help
You can now contact our live agent via whatsapp! ping +1 (714)-584-4466.
You will get plagiarism free custom written paper