Skip to main contentSkip to solution

The sequence of elements in the stack from top to bottom after operations PUSH, PUSH, PUSH, POP, PUSH, POP, PUSH, PUSH, PUSH, POP on the elements 10, 12, 8, 15, 5, 3, 6, 18, 9, 11 will be:

(A) 12

(B) 3

(C) 10

(D) 5

Solution

✅ Correct Option: 4

Take the elements in order, using one for each PUSH. A POP removes the top element and uses none.

OperationStack (bottom to top)
PUSH 1010
PUSH 1210, 12
PUSH 810, 12, 8
POP (removes 8)10, 12
PUSH 1510, 12, 15
POP (removes 15)10, 12
PUSH 510, 12, 5
PUSH 310, 12, 5, 3
PUSH 610, 12, 5, 6 is not formed; the stack is 10, 12, 5, 3, 6
POP (removes 6)10, 12, 5, 3

Read from top to bottom, the stack is 3, 5, 12, 10, which is (B), (D), (A), (C).

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question