Question: CI 2436:01L Data Structures Lab 4 - Chapter 6 Stack Implementation using a Linked List 2/14 Using the StackInterface created in Lab3, define a class

 CI 2436:01L Data Structures Lab 4 - Chapter 6 Stack Implementationusing a Linked List 2/14 Using the StackInterface created in Lab3, define

CI 2436:01L Data Structures Lab 4 - Chapter 6 Stack Implementation using a Linked List 2/14 Using the StackInterface created in Lab3, define a class LinkedStack that implements methods and creates an inner class Node . import java.util.EmptyStackException; public class LinkedStack implements StackInterface \{ private Node topNode; // References the first node in the chain public LinkedStack() i topNode = null; \} eoverride public void push (T newEntry) \& Node newNode = new Node (newEntry, topNode); topNode = newNode ; \} eoverride public T pop () 1 T top =peek(); topNode = topNode getNextNode () ; return top; \} eoverride public T peek () i if (isEmpty ()) throw new EmptyStackException(); else // Your code here \} public T pop() f T top = peek (); // Might throw EmptyStackException topNode = topNode. getNextNode (); return top; \} public boolean isEmpty() 1 return topNode == null; \} public void clear() 1 topNode = null; // Causes deallocation of nodes in the chain \} 3. Write java tester code to find the contents of the myStack after the following statements are completed and executed. \}

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!