Min Stack

You have a stack. Someone asks you for the minimum after every operation. The lazy answer: scan the whole thing. Let us see what “lazy” costs.

The Scan Tax

Twenty operations. 9 of them ask for the minimum. Watch what each getMin costs when you scan the whole stack.

Main stack (top ↑)
empty
op #1: push(5)
0/20Ops
0/9getMin calls
0/27Comparisons