Activity 01
Pair Programming: Factorial Duel
Pairs implement factorial iteratively with a loop and recursively with a base case. They trace both on paper for n=5, then run in an IDE to compare execution time and stack trace. Pairs swap codes to identify improvements.
Differentiate between the memory usage patterns of iterative and recursive algorithms.
Facilitation TipDuring Pair Programming: Factorial Duel, have students alternate roles every 5 minutes to keep both partners engaged in tracing and comparing approaches.
What to look forPresent students with two code snippets, one iterative and one recursive, solving the same problem (e.g., summing numbers from 1 to n). Ask them to identify which is which, and write one sentence explaining the primary difference in how they achieve the result.