Five items P, Q, R, S and T are pushed onto a stack one after another starting…
2021
Five items P, Q, R, S and T are pushed onto a stack one after another starting from P. The stack is popped four times and the popped elements are inserted into a queue. The two elements are deleted from the queue and pushed back onto the stack. Again one element is popped from the stack. The popped item is
- A.
P
- B.
R
- C.
Q
- D.
S
- E.
Question not attempted
Attempted by 534 students.
Show answer & explanation
Correct answer: D
Step-by-Step Solution
Let's trace the operations step by step.
1. Initial Pushes
Items P, Q, R, S, T are pushed onto the stack one after another.
Stack (Top to Bottom): [T, S, R, Q, P]
2. Pop Four Times and Insert into Queue
Pop T, S, R, Q and insert them into the queue in that order.
Queue (Front to Rear): [T, S, R, Q]
Stack (Top to Bottom): [P]
3. Delete Two Elements from Queue and Push Back to Stack
Delete T and S from the front of the queue.
Push T and S back onto the stack. Since T was deleted first, it is pushed first, then S.
Stack (Top to Bottom): [S, T, P]
4. Final Pop
Pop one element from the stack.
The top element is S.
Conclusion
The popped item is S.