AlgoScope

Base Case and Recursive Case

The recursive case shrinks the problem and the base case stops it. Without a base case the stack overflows.

Recursion, analysis, beginner
Call countDown(2), depth 2.countDown(3)countDown(2)bottomtoprunning

The Call Stack: No base case, stack overflow

Decision, step 3 of 10

countDown(2) prints 2 and calls countDown(1). Depth 2.

How the call stack works

Cost

Space
O(depth)

Taught by the same lesson

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