Question: 4. Write a method that implements a Queue using two stacks. You need to implement enqueue, dequeue and empty) methods using only the methods of

4. Write a method that implements a Queue using two stacks. You need to implement enqueue, dequeue and empty) methods using only the methods of the Stack: push(), pop0, and empty). You may not use any extra memory apart from two stacks. The code should be written in Java. (3 pt) public class QueueImplementation ( private Stack stack! = new ListStack(); private Stack stack2 = new ListStack(); public void enqueue (Object item) t FILL IN CODE public Object dequeueO FILL IN CODE public boolean empty C FILL IN CODE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
