Question: Write in JAVA with the following question: Write the pseudocode for a new data type MyStack that implements a stack using the fact that you
Write in JAVA with the following question:
Write the pseudocode for a new data type MyStack that implements a stack using the fact that you have access to a queue data structure with operations enqueue(), dequeue(), isEmpty(). Remember that every stack should have the operations push() and pop().
Hint: use two queues, one of which is the main one and one is temporary. Please note that you wont be able to implement both push() and pop() in constant time. One of the two will have to run in O(n), where n is the number of elements in the stack.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
