Activity 01
Pair Programming: Factorial Tracer
Pairs write a recursive factorial function in Python, test with inputs from 0 to 5, and draw the call stack on paper for n=4. Partners alternate coding and explaining each recursive step. End with modifying for memoization.
How does breaking a problem into recursive steps change our mental model of the solution?
Facilitation TipDuring Pair Programming: Factorial Tracer, have students alternate roles every three lines of code to ensure both practice tracing and writing recursive calls.
What to look forPresent students with a pseudocode snippet of a recursive function (e.g., factorial). Ask them to identify the base case and the recursive step, and explain in one sentence how the input changes in the recursive call.