Can somone implemnt these methods and explain. Thanks in Advance public interfac
ID: 3747391 • Letter: C
Question
Can somone implemnt these methods and explain. Thanks in Advance
public interface HeapAPI /ok k Determine whether the Heap is empty. @return this method returns true if the heap is empty; otherwise, it returns false if the heap contains at least one item. k/ boolean isEmptyO ok Inserts an item into the Heap @param item the value to be inserted. k/ void insert(E item); kok An exception is generated if this method is invoked by an empty heap. The maximum/minimum value is removed * from the heap if the heap is not empty and its effective size is reduced by 1. @return the maximum (in the case of a maxheap) or the minimum (in the case of a minheap) on the heap. @throws HeapException when the heap is empty k/ E remove() throws HeapException; ok An exception is generated if this method is invoked by an empty heap k @return the maximum (in the case of a maxheap) or the minimum (in the case of a minheap) on the heap. @throws HeapException when the heap is empty E peek() throws HeapException ki Gives the size of this heap @return the size of the heap; the effective size of the heap. int sizeO;Explanation / Answer
Below is the implementation of max heap child of the given interface:
In the same way you can implement min heap child class also.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.