Recursion Demo with Python Tutor

Programming Language

imperative / Python

Form

Representation

Attribution — Origin / Source

Collected by Craig S. Miller — Interview, Amber Settle

Conceptual Advantage

Demonstrates what happens to variable values when they are passed to a function. Distinguishes frame elements among each recursive call. Shows separate stack frames, each with own parameters and variables, for each recursive call.

Mapping

PLNM
frame group of elements with function name
parameter labeled box inside frame
local variable labeled box inside frame

Draws Attention To

Addition of each stack frame as each recursive call is made. Collapse of stack frame as function completes and returns value.

Use When

When introducing recursion

Cost

Requires use and understanding of the Python Tutor visualization tool

Details

Amber Settle presented this use of Python Tutor in an interview. She uses it to explain how recursive calls work when introducing recursion.

Notes from Interview

From the interview: Students "tend to use it a little bit mechanically so they tend to just step through it and not really think about what's actually happening on the screen."

Comments or Feedback?

Do you have feedback on this notional machine? Did you find a mistake, or do you have a request for improvement? You can create an Issue on GitHub, where the description is hosted. This way we can see your feedback and address it.

For this, you need a GitHub account. Then follow this link to see the source file of this page. In there, click the ... left of the highlighted line, then pick "Reference in a new issue".

Create an Issue on GitHub