Question
************ LinkedStack Methods ************ ************ CODE THAT IS TO BE USED AS REFERENCE/USED. ************ public class LLNode { private T data; private LLNode nextNode; public
************ LinkedStack Methods ************
************ CODE THAT IS TO BE USED AS REFERENCE/USED. ************
public class LLNode
private T data; private LLNode
----------------------------------------------------------------------------------------
import Support.LLNode;
public class LinkedStack
private LLNode
}
@Override public T peek() throws StackUnderflowException { // TODO Auto-generated method stub return null; }
@Override public boolean isEmpty() { // TODO Auto-generated method stub return (top == null); }
@Override public int size() { // TODO Auto-generated method stub return 0; }
@Override public void push(T data) { // TODO Auto-generated method stub LLNode
----------------------------------------------------------------------------------------
public interface StackInterface
----------------------------------------------------------------------------------------
public interface UnboundedStackInterface
void push(T element); }
----------------------------------------------------------------------------------------
public class StackOverflowException extends RuntimeException { public StackOverflowException() { super(); } public StackOverflowException(String message) { super(message); } }
----------------------------------------------------------------------------------------
public class StackUnderflowException extends RuntimeException { public StackUnderflowException() { super(); } public StackUnderflowException(String message) { super(message); } }
----------------------------------------------------------------------------------------
public class LinkedStackTester {
public static void main(String[] args) { LinkedStack
System.out.println("Empty: " + letterStack.isEmpty()); letterStack.push("a"); letterStack.push("b"); letterStack.push("c"); letterStack.push("d"); letterStack.push("e"); System.out.println("Empty: " + letterStack.isEmpty());
System.out.println("Pop: " + letterStack.pop()); System.out.println("Pop: " + letterStack.pop()); System.out.println("Pop: " + letterStack.pop()); System.out.println("Pop: " + letterStack.pop()); System.out.println("Pop: " + letterStack.pop()); System.out.println("Pop: " + letterStack.pop());
} }
1. Implement the methods specified for the unbounded stack (LinkedStack) *Add an inspector method inspect(int n). The method will return the nth element in the stack. By traversing the linked list to find that element (NOT USING LLNodeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started