Data Structures | Queue | Question 1
Following is C like pseudo code of a function that takes a Queue as an argument, and uses a stack S to do processing.
What does the above function do in general?
(A) Removes the last from Q
(B) Keeps the Q same as it was before the call
(C) Makes Q empty
(D) Reverses the Q
Explanation: The function takes a queue Q as an argument. It dequeues all items of Q and pushes them to a stack S. Then pops all items of S and enqueues the items back to Q. Since stack is LIFO order, all items of queue are reversed.