Activity 01
Pair Programming: Factorial Duel
Pairs write recursive and iterative factorial functions in Python. They add timing code with time module and test with inputs from 1 to 10000, noting failures or slowdowns. Pairs graph results and present one key insight to the class.
Compare the memory footprint of recursive and iterative solutions for the same problem.
Facilitation TipDuring Pair Programming: Factorial Duel, circulate to ensure both partners write and test their code independently before comparing results.
What to look forPresent students with two code snippets: one recursive and one iterative, both solving the same problem (e.g., calculating the sum of numbers from 1 to n). Ask them to identify which is which, and then write down one advantage of the iterative version and one advantage of the recursive version.