AlgoScope

Recursion

AnalysisbeginnerRecursion

A function that calls itself on a smaller input until a base case, each call parked as a frame until the one above it returns.

Decision · step 2 of 14The Call Stack: Summing a list recursively
sum(3 1 4 1 5)bottomtoprunning

The list starts with 3. Keep it, and call sum on the remaining 4 numbers. A smaller problem each time.

Open in the player →or start at step 2

What you will see

CALL -> new frame -> ... -> BASE CASE -> RETURN -> frame pops, value flows up.

How the call stack works →

Cost

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.

Screen readers: Each frame announces its function, arguments and depth; each step announces a call or a return with its value.

Reduced motion: Frames appear and disappear with crossfades instead of sliding.

Before this

Taught by the same lesson

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