Q41
NAT2 marksData structuresHardLet denote a queue containing sixteen numbers and be an empty stack. returns the element at the head of the queue without removing it from . Similarly returns the element at the top of without removing it from . Consider the algorithm given below.
while Q is not Empty do
if S is Empty OR Top(S) ≤ Head (Q) then
x:= Dequeue (Q);
Push (S, x);
else
x:= Pop(S);
Enqueue (Q, x);
end
end
The maximum possible number of iterations of the while loop in the algorithm is _______.
Sign in to save attempts.
Keys: Enter checks, ← → move between questions.
The solution is hidden while you attempt this question. It opens once you check or show the answer.