Skip to content

Films · Computer science · Recursion

heyprof · Expedition film

The tree behind recursion

On the way down the calls appear, on the way back the results, and the base case ends the descent.

Expedition film · 3 Min.

The tree behind recursion

Explained just right

0:00
−3:13
  • running
  • frame waiting
  • done, with return value

Try the app yourself

We store questions without any link to you; selected ones appear anonymously as frequent questions.

The tree behind recursion

NewNov 27, 2026 · 3 chapters

What happens when a function calls itself? Real Python runs step by step, and every call becomes a box in a tree. See the calls appear on the way down, the results on the way back, and why Fibonacci does the same sum three times. Inspired by invocation_tree by Bas Terwijn, University of Amsterdam.

Signature expedition · The person

Bas Terwijn

Software engineer and Python educator · University of Amsterdam

Bas Terwijn is a software engineer and educator at the University of Amsterdam, where he teaches Python.

He develops open-source tools that show what goes on inside a Python program: memory_graph draws references, mutability and copies as a graph, and invocation_tree shows function calls as a growing tree. Both also run as web debuggers right in the browser.

Signature app: The call tree

How a film works on heyprof

Every film here listens. Pause it, ask it questions and let it continue with your own examples.

  1. PauseTap pause or press the space bar. The film waits right at that moment.
  2. AskTap “Ask” and type what you want to know. The answer comes inside the film, with picture and voice.
  3. Steer itTell it what to show, for example “Do this with z = 2 − 3i”. The film sets up the app and works it out.
  4. Try it yourselfWhile it is paused, drag points and sliders yourself. “Continue” takes you back into the film.

Without an account: five questions per visit. With an account you can also ask by voice.

Comments