Frames pile up, values come back.
transcript
A function calls itself. Where does the computer keep the waiting calls? On the call stack. Let us watch one run.
The first call puts a frame on the stack. Each new call goes on top. The calls below wait. Three frames are open. Four frames. The last comment has no reply.
Each frame holds its own variables. It also holds the place to return to. So frames never disturb each other. A waiting call keeps its frame safe.
The base case returns one. Its frame leaves. The next frame adds itself and returns two. Then three. Then four.
The newest frame is always on top. Only the top frame can return. So the oldest call finishes last. The answer appears at the very end.
The most frames open at once is the depth. The depth is what reaches the limit. Remember this number for every recursion.
Calls pile up, and values come back in reverse. Full breakdown in the lecture.