1. Engineering
  2. Computer Science
  3. in python implement a stack using a single queue in...

Question: in python implement a stack using a single queue in...

Question details

in python, implement a stack using a single queue. In particular, you are given a queue Q that provides the method Q.size() to return its size at any point and the standard methods of queues (i.e, Q.enqueue(x) and Q.dequeue()). The requirement is to use such methods of Q to implement two methods S.push(x) and S.pop() for a stack S. What are the running times of your methods?

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution