You are on page 1of 4

Stacks Questions

Ans: (B)

What is the Optimized Method in which we have to perform the push(), pop() operations on Stack
and still implement the Queue
If S2 is empty, then bring all the elements from S1 to S2

Now, from S2, delete the topmost element i.e. ‘a’ from it. Here, the first element ‘a’ which is the first
inserted element of Queue.

Now, after deletion, we will not bring back elements from S2 to S1 i.e. known as optimization.

Sol:

Ans: (B)

You might also like