Question: Please write in Java Here is the heap class code: public class Heap { // We will assume a maximum heap dimension // You could

Please write in Java

Please write in Java Here is the heap class code: public class

Here is the heap class code:

public class Heap { // We will assume a maximum heap dimension // You could easily change the code to re-size if the heap gets full // Here, we just throw an exception in this case private static int defaultDim = 1024; HeapNode[] h; int last; public Heap() { h = new HeapNode[defaultDim]; last = -1; } public boolean isEmpty() { return (last last) return; for (int j = 0; j = h.length) throw new HeapFullException(); // Wrap the content in a node h[last] = new HeapNode(o, p); // Bubble up this node if need be int i = last; int parent; for (parent = getParent(i); i > 0 && h[i].key

------------------------------------------------------------------------------------------------------------------------------------------------------------

package Heap;

public class HeapEmptyException extends Exception { public HeapEmptyException() { super("Heap is empty"); } }

-------------------------------------------------------------------------------------------------------------------------------------------------------------

package Heap;

public class HeapEmptyException extends Exception { public HeapEmptyException() { super("Heap is empty"); } }

-------------------------------------------------------------------------------------------------------------------------------------------------------------

package Heap;

public class HeapFullException extends Exception { public HeapFullException() { super("Heap is full"); } }

-------------------------------------------------------------------------------------------------------------------------------------------------------------

package Heap;

public class HeapNode { Object content; int key;

public HeapNode (Object o, int priority) { content = o; key = priority;; } }

Add to the Heap class (minimum heap) provided to you in method that takes a heap and outputs its mirror image. For example; Mirror Min Heap 3 2 2 3 5 4 4 5 Your method should be called mirrorHeap(Heap h) Test your code with example above. Print out the heap and its mirror. Note you can take the content of each node the string "mirror". Also vou may have to write vour own print method . What is the big oh of your method? justify your

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!