BEGINNER · 8 MIN · FREE LESSON
Stack
Last in. First out.
Loading interactive lesson…
BEGINNER · 8 MIN · FREE LESSON
Last in. First out.
Loading interactive lesson…
Empty
An empty stack is ready for its first value.
Only the top is accessed. Holding n values requires n storage slots.
Measured reads + comparisons, seed 42. Plotted sample sizes respect each lesson’s explicit input limits.
Keyboard: Space play/pause · ←/→ step · R restart · 1–5 speed. Reduced motion disables transitions.
A stack of plates only lets you take the plate on top.
Use the player above to run, pause, scrub, or step backwards through a deterministic trace.
Switch to Try mode and predict each operation before revealing its result.
Push and pop touch only one end. Use best, average and worst presets to compare measured counters. The chart plots actual reads and comparisons for n = 8, 16, 32 and 64.
Choose JavaScript, Python, Java or C++ in the synchronized code panel.
Undo history, expression parsing and depth-first traversal.
Always check for an empty stack before a pop or peek.
Complete the three questions below, then use the module navigation to choose your next lesson.
MAKE IT STICK
Progress saves on this device and merges with your account after sign-in.
0 / 5000 · Saved on this device; synced when signed in.