Recursion solves a problem through smaller instances, requiring base cases and progress toward them. A call stack records suspended work, so elegant recursive code may use substantial memory.
Learning objectives
Explain recursion, complexity and computational thinking using a concrete example.
Apply the worked method and justify each step.
Recognise the limitation described in the final check.
The big idea
Recursion solves a problem through smaller instances, requiring base cases and progress toward them. A call stack records suspended work, so elegant recursive code may use substantial memory.
Complexity compares how resource use grows with input size. Big-O describes a bound, not an exact runtime; linear, logarithmic and quadratic growth matter more as inputs become large.
Equations and relationships
1+2+⋯+n=2n(n+1)
A closed-form alternative to a linear summation loop.
Worked example
A loop compares every pair in an n×n grid. How many comparisons for n=10?
Follow the solution
There are 10 choices in each dimension, giving 10×10=100 comparisons.
Investigate and explain
Predict the worked result before calculating. Change one input, record the new result, and explain which assumptions still hold.
Use the prediction activity below; a local model appears only where it supports this topic.