๐ WAYPOINT LESSON
Base cases are the whole grade
โญโญโญ advancedโณ 10 min read๐ Lesson 198 of 256
The hunting checklist: what cannot decompose, is there more than one base, does every branch shrink?
Base cases are the whole grade. An FRQ recursion task is scored almost entirely on: correct base case(s), correct progress toward them, and correct combination. The hunting checklist:
- What input cannot be broken down further? Empty string, length โค 1, n == 0, i == array length.
- Is there more than one base? Subset-sum has two: success (target == 0) and exhaustion (i == length with target != 0).
- Does progress always shrink?
substring(1)shrinks;n - 1shrinks;n / 2shrinks for n โฅ 1. A branch that does not shrink is infinite recursion (StackOverflowError). - Integer division and negatives:
n / 2of 1 is 0 โ make sure that lands on a base case, not below it.
Progress discipline on arrays/strings: pass the index (i+1), or
pass the remainder (substring(1)). Passing whole subarrays each
call is wasteful but legal; passing nothing new is illegal.