Consider the following pseudo code implementation of Enqueue and Dequeue operations using two initially empty very large stacks P and Q, with primitive stack operations PUSH and POP.

Stack P, Q;

Enqueue(key k)

       PUSH(k,P);

Dequeue( )

{

      if(Q is empty)

       {

         while(P is not empty)

             MISSING STATEMENT ;

        }

       return POP(Q);

}

Choose the correct statement in place of MISSING STATEMENT.(Ignore error handling).

1
PUSH(POP(P),Q)
2
PUSH(POP(Q),P)
3
return(POP(P))
4
None of the above

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation