Activity 01
Pair Programming: Factorial and Fibonacci Coders
Pairs write recursive functions for factorial and Fibonacci, test with inputs from 0 to 10, and trace calls on paper. They then rewrite one iteratively and compare outputs and code length. Discuss which approach suits each problem.
Design a recursive function to solve a given problem, identifying the base case and recursive step.
Facilitation TipBefore starting Pair Programming, ask each pair to sketch the call stack on paper for the first three steps of their chosen function to ensure they see how the frame grows and shrinks.
What to look forPresent students with a pseudocode snippet for a recursive function (e.g., factorial). Ask them to identify the base case and the recursive step, and explain what would happen if the base case were missing.