AlgoScope

Recursion

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.

Recursion, analysis, beginner
Call sum on 4 numbers.sum(3 1 4 1 5)bottomtoprunning

The Call Stack: Summing a list recursively

Decision, step 2 of 14

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

How the call stack works

Cost

Space
O(depth)

Leads to

Topics that need this one first.

Taught by the same lesson

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