The following operations are performed on an empty stack:
push(10) push(20) push(30) pop() push(46) pop() pop() push (34) push(12) pop() push(16) push(4)
Which of the following elements will be present on the stack?
A. 16
B. 10
C. 4
D. 34
The following operations are performed on an empty stack:
push(10) push(20) push(30) pop() push(46) pop() pop() push (34) push(12) pop() push(16) push(4)
Which of the following elements will be present on the stack?
A. 16
B. 10
C. 4
D. 34
Solution
✅ Correct Option: 3
A pop removes the most recently pushed element (last in, first out). Stack contents are shown from bottom to top.
| Operation | Stack |
|---|---|
| push(10) | 10 |
| push(20) | 10, 20 |
| push(30) | 10, 20, 30 |
| pop() removes 30 | 10, 20 |
| push(46) | 10, 20, 46 |
| pop() removes 46 | 10, 20 |
| pop() removes 20 | 10 |
| push(34) | 10, 34 |
| push(12) | 10, 34, 12 |
| pop() removes 12 | 10, 34 |
| push(16) | 10, 34, 16 |
| push(4) | 10, 34, 16, 4 |
The final stack holds 10, 34, 16 and 4, so all of A, B, C and D are present.
Related questions:
2025: 21 May Shift 1
2026: 24 May Shift 1
2026: 21 May Shift 1
2026: 26 May Shift 1