Question discussion

An empty stack undergoes these operations in order: push 1, push 2, push 3, pop, push 4, pop, pop. Which element is now at the top of the s…

1182Medium DSSSB TGT Computer Science 0 replies 1 views
0

An empty stack undergoes these operations in order: push 1, push 2, push 3, pop, push 4, pop, pop. Which element is now at the top of the stack?

  • A1
  • B2
  • C3
  • D4
Correct answer: A

Explanation

After the pushes the stack is [1, 2, 3]; pop removes 3, push 4 gives [1, 2, 4], then two pops remove 4 and 2, leaving [1].

Discussion 0

Nobody has replied yet. Start the discussion!