The following sequence of operations is performed on a stack:
The sequence of values popped out is
View worked solution
Answer: B
We can trace the state of the stack and the sequence of popped values step-by-step:
- PUSH(10): Stack =
- PUSH(20): Stack =
- POP: Pops . Stack =
- PUSH(10): Stack =
- PUSH(20): Stack =
- POP: Pops . Stack =
- POP: Pops . Stack =
- POP: Pops . Stack =
- PUSH(20): Stack =
- POP: Pops . Stack =
Combining the popped values in order, we get: .
Free practice · Your answers on this page are not saved.
