Question: python please IMPORTANT: For this exercise, you will be defining a function which USES both the Stack and Queue ADTs. Your code can make use

python please IMPORTANT: For this exercise, you will be defining a functionpython please

IMPORTANT: For this exercise, you will be defining a function which USES both the Stack and Queue ADTs. Your code can make use of any of the Queue ADT methods: Queue (), enqueue (), dequeue(), peek(), size() and is_empty() and any of the Stack ADT methods: Stack(), push(), pop(), peek (), size() and is_empty(). Write a function called reverse_queue (a_queue) which takes a Queue object as a parameter. The function must modify the parameter queue so that the elements in the queue are rearranged into reverse order. Use a Stack object to reverse all the elements in the queue. You can assume that an implementation of the Queue ADT and Stack ADT are given. For example: Test Result 3 2 q1 = Queue () 91. enqueue (1) q1.enqueue (2) 91. enqueue (3) reverse_queue (91) while not q1.is_empty(): print(q1. dequeue()) 1 91 = Queue () 91. enqueue (1) reverse_queue (91) while not q1.is_empty(): print (q1. dequeue())

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!