What does the below function do in general?
(A) Removes the last element from the queue, Q
(B) Keeps the queue, Q same as it was before the call
(C) Makes queue Q empty
(D) Reverses the queue 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 the queue are reversed.
Quiz of this Question
Please comment below if you find anything wrong in the above post