01.01 · Lesson
Start Here: Learn Recursion the Right Way
You can solve easy problems. Maybe you have memorised some DP answers. But a new recursion question still feels hard. This module gives you one method that works on any problem. No memorising.
Why recursion feels hard
- The wrong picture. Many students think a recursive call jumps back to the top, like a loop. It doesn’t. Each call is a new copy of the method with its own variables, and the old copy waits.
- Tracing every call. Following every call in your head gets confusing fast. Experts don’t do it. They trust the smaller call, and you’ll learn how.
- Memorised answers break. Change one rule and the memorised code is useless. A method still works.
These come from studies of how students learn recursion (Kahney 1983; Götschi, Sanders and Galpin 2003; George 2000; Haberman and Averbuch 2002).
The method
- See it: what Java does on each call.
- Recipe: the promise, the base case, the smaller step.
- Draw the tree: what choices do you have?
- Spot repeats: is the same call made twice?
- Memo: save each answer. Then write a table if you need one.
Try it now
Press Next a few times. Watch the code, the stack and the tree.
fact(4) waits for fact(3), which waits for fact(2), and so on. The answers come back in reverse order.
How this module helps you
- The visualiser (above) shows every call step by step.
- “Derive it with me” boxes ask you one question at a time and build the Java code from your answers. A wrong answer tells you why it’s wrong.
- Every problem uses the same steps: promise, base case, choices, code, memo.
Short on time? A 5-day plan
| Day | Do this |
|---|---|
| 1 | Chapter 1 lessons, Trace the Output, the first four problems |
| 2 | The rest of chapter 1, the chapter 2 lessons, Subsets, Count Subsets With Sum K |
| 3 | Chapter 3: Climbing Stairs, Frog Jump, House Robber, Subset Sum |
| 4 | Which DP Is It?, grids, take-or-skip and coins, with their problems |
| 5 | Two strings, increasing subsequences, the exam kit and the mock test |
Check yourself
Question 1 of 2
A test changes one rule of a DP problem you memorised. What helps most?
Question 2 of 2
What really happens when a method calls itself?
Item 1 of 44 · updated 2026-10-13