GATEverse
← GATE CSE 2016 Set 1

Q41

NAT2 marks

Let QQ denote a queue containing sixteen numbers and SS be an empty stack. Head(Q)Head(Q) returns the element at the head of the queue QQ without removing it from QQ. Similarly Top(S)Top(S) returns the element at the top of SS without removing it from SS. 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.

Loading…