<aside> 📚
L4: Recurse! covers what recursion is, its structure (base case + recursive clause), the connection to induction, programming recursively in Java (factorial, integer powers with fast exponentiation, GCD via Euclid's algorithm), helper functions for efficiency, the cost of recursion, when not to recurse (Fibonacci), and the analysis of recursive algorithms (factorial, power, Towers of Hanoi).
</aside>
<aside> 📅
Week 2 (w/c 2 Feb) — Lecture 4 of 26 | Tutorial 2 applies (same as L3)
</aside>
<aside> 💡
Key principle: Recursion reduces a problem to one or more smaller problems of the same type until a trivial base case is reached. It is the mirror image of induction — recursion defines things, induction proves things about them. Always start with the base case.
</aside>
Recursion is a strategy where we reduce solving a problem to solving one or more smaller problems of the same type, repeating until we reach a trivial case.
Example — factorial:
$n! = n \times (n-1)!$ with $0! = 1$