Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started