Visualizing recursion
20-minute lesson · module-recursion-04
You are previewing this course as a guest
Read anything and run any exercise you like. It all runs in your own browser, so nothing here is saved: no XP, no progress, and the AI tutor needs an account. Sign in and your work starts counting.
Visualizing recursion
20-minute lesson · module-recursion-04
- Draw the call tree of a recursive function such as power or Fibonacci.
- Distinguish linear recursion (one call) from tree recursion (two calls).
- Explain why naive Fibonacci repeats work and grows explosively.
- Trace the order in which recursive calls are made and returned.
Source attribution
Status: adapted
How to Think Like a Computer Scientist: Interactive Edition — source · Recursion / Visualizing Recursion
Adaptation notes. Reading rewritten in our voice. Instead of the chapter's turtle drawings (which need a graphics canvas), we visualize recursion through the CALL STRUCTURE of power (linear) and Fibonacci (tree), with a codelens that prints the calls as they happen. Hidden tests check both functions.
License notes. Original chapter is GNU FDL 1.3 (Brad Miller, David Ranum, and the upstream Elkner/Downey/Meyers text). No verbatim text reproduced.