Question: Reverse a queue using recursion Given a queue, write a recursive function to reverse it. Standard operations allowed : enqueue(x) : Add an item x
Reverse a queue using recursion Given a queue, write a recursive function to reverse it. Standard operations allowed : enqueue(x) : Add an item x to rear of queue. dequeue() : Remove an item from front of queue. isEmpty() : Checks if a queue is empty or not. Examples : Input : Q = [5, 24, 9, 6, 8, 4, 1, 8, 3, 6] Output : Q = [6, 3, 8, 1, 4, 8, 6, 9, 24, 5]
DATASTRUCTURE USING JAVA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
