Activity 01
Pair Programming: Recursive vs Iterative Space Comparison
Pairs implement Fibonacci sequence recursively and iteratively. They add print statements to log memory usage or stack depth, then run both on increasing inputs and graph results. Discuss which version suits memory-limited devices.
Differentiate between time complexity and space complexity in algorithm analysis.
Facilitation TipFor Pair Programming: Recursive vs Iterative Space Comparison, set a strict recursion depth limit to prevent stack overflows and guide students to track memory with system monitors before and after runs.
What to look forPresent students with two code snippets, one recursive and one iterative, solving the same problem (e.g., factorial). Ask them to identify which is likely to have higher space complexity and explain why, referencing stack frames.