Skip to main contentSkip to solution

Consider the given stack with 6 elements at the beginning as shown below:

2573113

If the following operations are performed in order

push(10), pop(), push(15), pop(), push(35), pop(), pop() , pop(), pop()

Specify the order of elements in which they are popped in last four pop() operations.

A. 3

B. 1

C. 13

D. 35

Solution

✅ Correct Option: 1

The last element, 13, is at the top of the stack. Each push(x) is immediately followed by a pop() that removes x, so 10, 15 and 35 are popped in turn and the stack returns to its original state.

The last four pop() operations are 35 (from the push(35) pair), then the original elements from the top: 13, 1, 3.

The popped order is 35, 13, 1, 3, which is D, C, B, A.

Keyboard Shortcuts

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