Suppose the stack operations are implemented using the queue operations. Push(x) and Pop() are stack operations whereas enqueue(x) and dequeue() are queue operations.

Consider the following code

Pop() {return Q.dequeue();}

Push(x)

{

n=Q.size(); /*Q.size() returns the number of elements in queue Q*/

Q.enqueue(x);

For(i=0; i

}

Find the missing statement X to perform the push operation correctly.

1
Q.enqueue(x);
2
Q.enqueue(Q.dequeue());
3
Q.dequeue(Q.enqueue(x));
4
Q.dequeue();

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation