Question: I have to implement this interface in Heap class and the instructions are like this: This class models an array-list-based min binary heap that implements

 I have to implement this interface in Heap class and the

I have to implement this interface in Heap class and the instructions are like this: "This class models an array-list-based min binary heap that implements the * HeapAPI interface."

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

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!