Skip to main contentSkip to solution

In a stack of Size 'N', if there are 'M' elements inserted into the stack and then 'M/2' are popped out. What is the remaining number of elements left in the stack? Assume 'M' < 'N'.

Solution

✅ Correct Option: 2

Elements left == elements pushed −- elements popped

M−M2=M2M - \dfrac{M}{2} = \boxed{\dfrac{M}{2}}

The size NN is only the maximum capacity of the stack, so it does not affect the count of elements present.

Keyboard Shortcuts

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