Call Stack
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) needs fact(4) before it can multiply, so it calls it. The new frame goes on top and fact(5) waits below it.
What you will see
Frames push on call and pop on return, each showing its arguments.
Cost
| push frame | O(1) |
|---|---|
| pop frame | O(1) |
| Space | O(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
Related
Taught by the same lesson
The Call Stack covers these too, in the same run.