Suppose you are given an implementation of a queue of integers. Consider the…
GATE · 2007 · IT
Suppose you are given an implementation of a queue of integers.

Consider the following function:
void f(queue Q)
{
int i;
if (!isEmpty(Q))
{
i = delete (Q);
f(Q);
insert(Q, i);
}
}
What operation is performed by the function f?
- A.
Leaves the queue Q unchanged
- B.
Reverses the order of the elements in the queue Q
- C.
Deletes the element at the front of the queue Q and inserts it at the rear keeping the other elements in the same order
- D.
Empties the queue Q
Attempted by 736 students.
Show answer
Correct answer: B
The worked solution is available to enrolled students.
Video solution available to enrolled students.
Explore the full course: Iocl Engineers Officers Grade A Paper 2
Loading lesson…