AlgoScope

Pop

Take the top item off. Only the top is ever touched.

Stack and queue algorithms, algorithm, beginner
Pop removes 9, the top item. 2 items remain.53bottomtop
Pop removes 9, the top item. 2 items remain.53bottomtop

Stack: Push, pop, peek

Decision, step 5 of 10

pop returns 9: the most recently pushed item leaves first.

Cost

Best
O(1)
Average
O(1)
Worst
O(1)
Space
O(1)

Before this

Taught by the same lesson

Stack covers these too, in the same run.