Suppose Stack operations are implemented using Queue Operation. Push(x) and Pop() are stack operations whereas enqueue(x) and dequeue are Queue operations.
Consider the code:
pop()
{
return Q.dequeue();
}
push(x)
{
n= Q.size(); //Q.size() returns the number of elements in the Queue Q.
Q.enqueue(x);
for(i=0;i<n;i++)
{
X STATEMENT
}
}
Find the missing statement X STATEMENT to perform Push() operation correctly
(A) Q.enqueue(x)
(B) Q.enqueue(Q.deqeue())
(C) Q.dequeue(Q.enqueue(x))
(D) Q.dequeue()