Using a Linked List as the underlying data storage mechanism, implement both a Stack and a Queue.
Because there is no traversal involved working with a stack or a queue all the method’s time complexities are linear O(1).
public Stack() Instantiates an empty stack object.
public void push(T value) Adds a new element to the top of the stack.
public T pop() Returns the top element’s value on the stack and removes it from the stack.
public T peek() Returns the top element’s value on the stack but does not remove it from the stack.
public boolean isEmpty() Returns true if the stack is empty.
public int size() Returns the number of elements on the stack.
public Queue() Instantiates an empty queue object.
public void push(T value) Adds a new element to the back of the queue.
public T pop() Returns the top element’s value on the queue and removes it from the queue.
public T peek() Returns the top element’s value on the queue but does not remove it form the queue.
public boolean isEmpty() Returns true if the queue is empty.
public int size() Returns the number of element on the queue.