Stack · Class 12 · CBSE · Science Computer Science

A stack initially contains [10, 20], with 20 at the top. The operations pop(), push(35), push(40), and pop() are performed in order. What is the top…

Practice question from Stack (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-5F8FB9

A stack initially contains [10, 20], with 20 at the top. The operations pop(), push(35), push(40), and pop() are performed in order. What is the top element of the resulting stack?

  1. A.10
  2. B.20
  3. C.35Correct answer
  4. D.40

Solution

The first pop() removes 20. After pushing 35 and 40, the final pop() removes 40, leaving 35 at the top.

More from Stack

All of Stack

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed