Question:medium

What will be the sequence of elements removed from the stack after performing the following operations?
Operations:
PUSH(10)
PUSH(20)
POP()
POP()
PUSH(30)
PUSH(40)
POP()
POP()
Options:
(A) 10
(B) 20
(C) 30
(D) 40
Choose the correct sequence from the options given below:

Updated On: Jan 16, 2026
  • (A), (B), (C), (D)
  • (A), (B), (D), (C)
  • (B), (A), (D), (C)
  • (B), (A), (C), (D)
Show Solution

The Correct Option is C

Solution and Explanation

A stack operates on the Last In, First Out (LIFO) principle, where the most recently added element is the first to be retrieved. Examining the sequence of operations:

1. PUSH(10): Stack: [10]
2. PUSH(20): Stack: [10, 20]
3. POP(): Removes 20. Stack: [10]
4. POP(): Removes 10. Stack: []
5. PUSH(30): Stack: [30]
6. PUSH(40): Stack: [30, 40]
7. POP(): Removes 40. Stack: [30]
8. POP(): Removes 30. Stack: []

The elements removed from the stack, in order, are 20, 10, 40, 30. Corresponding to the provided options, the correct sequence is (B), (A), (D), (C).
Was this answer helpful?
0


Questions Asked in CUET (UG) exam