Reducing a problem to a smaller version of itself.
The simplest recursive pattern: take n, do something, then call the same method with n - 1, and stop at zero.
Recursive reduction is the foundational recursion pattern. A method handles the case for input n by handling something small directly and delegating the rest to recursiveMethod(n - 1). Eventually n reaches a base case — usually 0 or 1 — where the method returns without recursing.
Every reduction-style recursion needs two parts: a base case that stops recursion, and a recursive case that makes progress toward the base case.
On the AP exam, this is the first recursion pattern tested. Mastering it is required before any other recursion topic makes sense.
Base case stops; recursive case shrinks the input.
Each call reduces n by one toward zero.
The reduction template
public void recursiveMethod(int n) {
if (n <= 0) return; // base case
// do something with n
recursiveMethod(n - 1); // shrink toward 0
}
Print countdown
public void countDown(int n) {
if (n <= 0) return;
System.out.println(n);
countDown(n - 1);
}
Calling countDown(3) prints 3, 2, 1.
Sum from 1 to n
public int sum(int n) {
if (n <= 0) return 0;
return n + sum(n - 1);
}
Each call adds its value of n to the sum of everything smaller. sum(0) returns 0 — the base case prevents infinite recursion.
Power (positive exponent)
public int power(int base, int exp) {
if (exp == 0) return 1;
return base * power(base, exp - 1);
}
Each call peels off one factor of base; the exponent counts down to 0.
Why progress matters
Without n - 1 (or some step toward the base case), recursion never terminates — it crashes with a stack overflow. Every recursive call must move strictly closer to the base case.
Reduction vocabulary.
The terms AP uses in every recursion question.
- Recursion — a method calling itself.
- Base case — non-recursive branch that ends the chain.
- Recursive case — branch that calls the method on a smaller input.
- Reduction — making the input smaller toward the base case.
- Termination — reaching the base case in finite time.
- Stack overflow — what happens when recursion doesn't terminate.
How reduction is tested.
Base case correctness and progress dominate.
- Base case first. Always check the stop condition before recursing.
- Recursive call moves toward base.
n - 1, notn. - Trace the call chain. MCQs ask you to predict total output or return value.
- Identify infinite recursion. Missing base case or no progress.
Trace sum(4) call by call.
Calls go down; values bubble up.
Setup. Using sum defined above. Compute sum(4).
Calls go down (each waits on the next):
- sum(4) → 4 + sum(3)
- sum(3) → 3 + sum(2)
- sum(2) → 2 + sum(1)
- sum(1) → 1 + sum(0)
- sum(0) → returns 0 (base case!)
Returns bubble up:
- sum(1) = 1 + 0 = 1
- sum(2) = 2 + 1 = 3
- sum(3) = 3 + 3 = 6
- sum(4) = 4 + 6 = 10
Answer: 10.
Why this matters. Each call pauses until its inner call returns. The chain "winds up" going down, then "unwinds" going back, with each level completing its arithmetic in turn.
Reduction pitfalls.
Most cause infinite recursion or wrong return.
- Missing base case. Recursion never stops → stack overflow.
- Calling with the same n. No progress; infinite recursion.
- Calling with n + 1. Moves away from base case.
- Forgetting to return the recursive result. Method returns nothing useful.
- Wrong base value. sum(0) should return 0; returning 1 produces wrong answers.
Reduction template parts.
Three lines; one pattern.
Recursive Reduction Reference
AP Quick Reference| Part | Purpose | Example |
|---|---|---|
| Base case | Stop recursion | if (n <= 0) return 0; |
| Action on n | Use current value | n + ... |
| Recursive call | Shrink the input | ... + sum(n - 1) |
| Direction | Toward base | n decreases. |
How to master recursive reduction.
Start with the base case; then write one step.
Use the three practice tools below this lesson in order:
- MCQ Practice — for each option, identify the base case and verify it terminates.
- Java Lab — write countDown, sum, and power. Trace small inputs to verify return values.
- FRQ Practice — for every recursive method, write the base case first, then the recursive case.
If you can identify the stopping condition before writing any code, recursive reduction becomes mechanical.
Practice — attempt these now.
AP-style assessments aligned to this lesson. Time them.
AP CSA Unit 11 Topic 01 Recursive Reduction FRQ Practice
AP-style topic practice assessment