Skip to main contentSkip to solution

What is an underflow condition?

Solution

✅ Correct Option: 1

Underflow occurs when an element is removed from a data structure that has nothing in it. In a stack, this means calling pop on an empty stack, since there is no top element to remove.


Option 4: this is overflow, which happens when pushing into a stack that has no space left.

Options 2 and 3: popping from a full stack and pushing into an empty stack are normal operations, so neither is an error condition.

Memory trick: underflow means "nothing left to take out" (pop on empty), overflow means "no room to put in" (push on full).

Keyboard Shortcuts

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