Question: Implement the StackADT interface from earlier this semester using the LinkedHeap implementation from the Java Foundations book. Call your class HeapStack and include it in

Implement the StackADT interface from earlier this semester using the LinkedHeap implementation from the Java Foundations book. Call your class HeapStack and include it in the jsjf package. Keep in mind that a stack is a LIFO structure. Thus, the comparison in the heap will have to be according to order entry into the stack. You must use a heap to implement a stack to receive credit for this assignment. Your HeapStack class should work when included in the jsjf package provided in class with no modification (other than completing the methods left as assignments).

package jsjf;

/**

* Defines the interface to a stack collection.

*

* @author Java Foundations

* @version 4.0

*/

public interface StackADT

{

/**

* Adds the specified element to the top of this stack.

* @param element element to be pushed onto the stack

*/

public void push(T element);

/**

* Removes and returns the top element from this stack.

* @return the element removed from the stack

*/

public T pop();

/**

* Returns without removing the top element of this stack.

* @return the element on top of the stack

*/

public T peek();

/**

* Returns true if this stack contains no elements.

* @return true if the stack is empty

*/

public boolean isEmpty();

/**

* Returns the number of elements in this stack.

* @return the number of elements in the stack

*/

public int size();

/**

* Returns a string representation of this stack.

* @return a string representation of the stack

*/

public String toString();

}

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!