Skip to main contentSkip to solution

Suppose the stack capacity is 4, and we are performing operations of PUSH, PUSH, PUSH, PUSH and POP, what will happen to the stack after these operations?

Solution

✅ Correct Option: 4

Four PUSH operations fill a stack of capacity 4 exactly, so no overflow occurs. The POP then removes the top element, leaving 3 elements.


Option 2: overflow happens only when a PUSH is attempted on an already full stack, which would be a fifth PUSH here.

Option 1: underflow happens only when a POP is attempted on an empty stack.

Option 3: the stack has 4 elements only before the POP.

Keyboard Shortcuts

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