AlgoScope

Call Stack

Data structurebeginnerLinear Structures

The runtime stack of function frames, pushed on every call and popped on every return; the reason recursion works and overflows.

Decision · step 2 of 14The Call Stack: fact(5) down and back up
fact(5)bottomtoprunning

fact(5) needs fact(4) before it can multiply, so it calls it. The new frame goes on top and fact(5) waits below it.

Open in the player →or start at step 2

What you will see

Frames push on call and pop on return, each showing its arguments.

How the call stack works →

Cost

push frameO(1)
pop frameO(1)
SpaceO(depth)

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

Leads to

Topics that need this one first.

Taught by the same lesson

The Call Stack covers these too, in the same run.