AlgoScope

Stack

Data structurebeginnerLinear Structuresalso called LIFO

Only the top is reachable. The last thing down is the first thing up.

Decision · step 5 of 10Stack: Push, pop, peek
53bottomtop

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

Open in the player →or start at step 5

What you will see

Items drop onto the TOP and lift off the TOP; nothing below moves.

How stack works →

Cost

pushO(1)
popO(1)
peekO(1)
searchO(n)
SpaceO(n)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.

Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.

Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.

Before this

Taught by the same lesson

Stack covers these too, in the same run.