Week 4: Recursion & Recurrence

Computer Algorithms (506994-002)

Ridho Hendra, Ph.D · Dept. of Intelligent Computing · Mon [1-3] · Building A, Room 703
Department of Intelligent Computing

Where We Are

Wk 1
Introduction
Wk 2
Algorithm Concepts
Wk 3
Complexity Analysis
Wk 4
Recursion & Recurrence
Wk 5
Basic Sorting
Wk 6
Advanced Sorting
Wk 7
Searching
Wk 8
Midterm Exam
Wk 9
Divide & Conquer
Wk 10
Greedy Algorithms
Wk 11
Dynamic Programming I
Wk 12
Dynamic Programming II
Wk 13
Graph Representation
Wk 14
Shortest Path
Wk 15
Final Exam
Department of Intelligent Computing

Describe It Using Itself

A quick warm-up, resolved directly. No code needed yet.

How would you tell a friend to count down out loud from 5 to 1?

  • Method A: "Start at 5. Say it. Subtract 1. Say that. Keep going until you say 1."
  • Method B: "To count down from any number N: say N, then count down from N minus 1. To count down from 1: just say '1' and stop."

Only Method B describes itself, using itself - "count down from N"
is defined partly in terms of "count down from N minus 1." Method A
never refers back to its own instruction. Notice the one number where
Method B's self-reference stops: 1, the case answered directly, no
further self-call. That stopping point is today's whole topic, long
before we have a name for it.

Department of Intelligent Computing

Last Week, This Week

  • Last week delivered: a precise, provable vocabulary (Big-O) for comparing how algorithms' costs grow - no more guessing whether one method is "better."
  • Last week left broken: some of CampusNav's algorithms are about to call themselves. Big-O tells us how to compare two growth rates once we have them - it does not tell us how to find the growth rate of a formula that refers to itself.
Department of Intelligent Computing

Key Words Today

  • Recursion: solving a problem by solving a smaller version of the same problem.
  • Base case: the smallest input a recursive method answers directly, no further self-call.
  • Recursive case: the step where the method calls itself on something smaller.
  • Call stack: where the computer keeps track of every call that's still "waiting" for a smaller one to finish.
Department of Intelligent Computing

The Demo That Never Finished

An intern is building CampusNav's new multi-stop tour feature:
"take me to the library, then the gym, then my friend's dorm." Timing
it is easy - the total walking time is just the first leg, plus
whatever the rest of the trip takes. Feeling confident, the intern
adds one more button for a class demo: "show me every possible order
to visit these stops, so I can pick the shortest by eye." It works
fine on the 3-stop example. During the live demo, someone picks 10
stops. The laptop fan spins up, the screen freezes, and class ends
before it produces a single order. Nobody in the room can explain
why - it's the exact same idea that worked a minute ago, just with a
few more stops.

Department of Intelligent Computing

This Explodes As Stops Grow

3 stops (the demo that worked)
6 possible orders
6 stops
720 possible orders
10 stops (what froze the laptop)
3,628,800 possible orders
Illustrative widths; the order counts themselves are exact.

Seven more stops turned "instant" into "did not finish before class ended."

Department of Intelligent Computing

What This Actually Costs

  • A recursive method with no clear stopping point - or one that branches too eagerly - can freeze or crash an app (a stack overflow) with zero warning until someone finally hits the input that triggers it.
  • Without a way to predict a recursive method's cost before running it, "it worked in the demo" tells you nothing about what happens with 10 stops instead of 3, or 1,200 rooms instead of 12.
Department of Intelligent Computing

What This Actually Costs, In Industry

In industry: tracing a call stack and writing down a recurrence are two of the most common whiteboard-interview questions (factorial, Fibonacci, tree traversal) - precisely because they separate candidates who understand what the machine is actually doing from those who memorized syntax. Uncontrolled recursion is also a real production bug: deeply nested or attacker-crafted input has crashed real parsers and services with stack-overflow errors.
Department of Intelligent Computing

This Week's Question

"How do we trace, bound, and predict the cost of an algorithm that calls itself?"
Department of Intelligent Computing

By the End of This Week, You Can

  1. Trace a recursive algorithm's call stack by hand, frame by frame, down to the base case and back.
  2. Convert a simple recursive algorithm into an equivalent iterative one, and vice versa.
  3. Write the recurrence relation that describes a recursive algorithm's cost.
  4. Solve a simple recurrence with substitution or a recursion tree, and read the Master Theorem's three cases intuitively.
Department of Intelligent Computing

This Problem Is Not New (1)

You just felt the pain. Now: who else felt it, and what did they do?
  • Self-reference is far older than computers: "" and the Fibonacci sequence are centuries-old mathematical definitions written in terms of themselves. Mathematical induction - proving a statement for all by showing it for a base case and then for " given " - is the same idea, formalized for proofs.
  • Early programming languages didn't automatically support it: FORTRAN (1957) explicitly forbade a procedure from calling itself, because nobody had yet built a runtime mechanism to keep track of many "waiting" calls at once.
Department of Intelligent Computing

This Problem Is Not New (2)

The mechanism that finally made recursion practical.
That mechanism is the call stack. Once LISP (John McCarthy, 1958) and ALGOL 60 built it in, recursive procedures went from mathematical curiosity to a normal tool - because so many real problems are naturally defined in terms of smaller versions of themselves.
Department of Intelligent Computing

A Motivating Example: Defining By Itself

The oldest recursive idea in this course, written out plainly.

  • - an answer given directly, no further self-reference.
Department of Intelligent Computing

Unwinding

The same definition, expanded one step at a time.

Notice the shape: one case that answers directly, one case that
answers in terms of a smaller version of the same question. That shape
is what today formalizes.

Department of Intelligent Computing

Recursion: Definition

A mathematical habit centuries old, a warm-up you just ran by hand, and a frozen demo all point at one idea. Here it is, precisely (CLRS - Cormen/Leiserson/Rivest/Stein's Introduction to Algorithms, 4th ed, §4.3-4.5).

A recursive algorithm solves a problem by solving one or more
smaller instances of the same problem (the recursive case),
until it reaches an instance small enough to answer directly (the
base case).

Department of Intelligent Computing

Recursion: Base Case vs. Recursive Case

The definition, unpacked into its two working parts.
  • Base case: the smallest input the algorithm can answer with no further self-call - it is what stops the recursion.
  • Recursive case: expresses the answer for a bigger input in terms of the answer for a smaller one.

Every recursive algorithm needs both. Miss the base case, and the recursion never stops.

Department of Intelligent Computing

Key Words Today

  • Recurrence relation: a formula for an algorithm's cost, written in terms of its own cost on smaller input.
  • Substitution method: guess the closed-form answer to a recurrence, then prove the guess by induction.
  • Recursion tree: a diagram of every recursive call, used to sum an algorithm's total cost level by level.
  • Master Theorem: a shortcut for solving the common divide-and-conquer recurrence shape (previewed today, proven Week 9).
Department of Intelligent Computing

Recursion vs. Iteration: Same Idea, Two Forms

Same answer, two different ways to describe "what's left to do."

Recursive

FACTORIAL(n):
    if n == 0:
        return 1
    return n * FACTORIAL(n - 1)

Iterative

FACTORIAL(n):
    result = 1
    for i = 1 to n:
        result = result * i
    return result

Both compute the same answer. The recursive version trades an
explicit loop counter for the call stack keeping track of "what's left."

Department of Intelligent Computing
Call-stack tracing · worked example

Tracing the Call Stack: factorial(4)

Five frames stack up before a single multiplication happens - then everything unwinds.
GoalTrace factorial(4) all the way down to the base case, and all the way back up.
1
Going down
factorial(4) needs factorial(3), needs factorial(2), needs factorial(1), needs factorial(0) - five frames stacked, waiting.
→
2
Base case hits
factorial(0): the base case. Returns 1 immediately, no further call.
→
3
Coming back up
factorial(1) = 1×1 = 1. factorial(2) = 2×1 = 2. factorial(3) = 3×2 = 6.
→
4
Final unwind
factorial(4) = 4×6 = 24, final answer. The base case is what the whole unwind is built from - it bounds how deep the stack could ever grow.
✓
Conclusionfactorial(4) = 24, traced through 5 stacked frames and back.
💡
Key takeawayAt the moment factorial(0) returns, four frames are still waiting - factorial(1) through factorial(4) - each paused on its own multiplication until the call below it finishes.
Department of Intelligent Computing

Another Conversion: Summing 1 to

Same recursive/iterative shape as factorial - a different base operation, traced in one line.

Recursive

SUM(n):
    if n == 0:
        return 0
    return n + SUM(n - 1)

Iterative

SUM(n):
    total = 0
    for i = 1 to n:
        total = total + i
    return total

Same recurrence shape as factorial: . Five
frames deep, same as factorial(4) - the base case SUM(0) = 0 is
what the whole chain unwinds from.

Department of Intelligent Computing

Recurrence Relations: Writing Cost as a Formula

Now let's measure the trace we just watched, not just narrate it.
  • Each call to factorial(n) does work of its own (one comparison, one multiply) plus whatever factorial(n-1) costs.

  • This is the "self-referential formula" that stumped us at the end of last week - a cost defined in terms of itself, on smaller input.
Department of Intelligent Computing

Not Every Recursion Shrinks by One

A second shape, distinct from `factorial`'s.

Not every recursive algorithm shrinks by 1 each call. Algorithms that
split their input in half give a different shape:

  • We'll meet this exact recurrence again in Week 6 - it is merge sort's cost.
Department of Intelligent Computing

A Quick Primer: Mathematical Induction

Dominoes, not magic - and it's about to become this course's main proof tool.

To prove a statement true for every whole number , two steps
replace checking each one at a time:

  1. Base case: true for the smallest (the first domino falls).
  2. Inductive step: if it's true for some , it must also be true
    for (each falling domino knocks over the next one) - like
    climbing a staircase, knowing each step leads to the next.
This is exactly what the substitution method, next, does: guess the closed-form answer, then use induction to prove the guess is right.
Department of Intelligent Computing
Substitution method · worked example 1 of 2 (moderate)

Solving by Substitution

Guess the answer, then prove the guess by induction.
GoalProve T(n) = O(n) for T(n) = T(n−1) + d, some constant d.
1
Guess
Formally: T(n) ≤ cn for a constant c and all n ≥ n0.
→
2
Base case
True for small n once c is chosen large enough to cover T(n0).
→
3
Inductive step
Assume T(n−1) ≤ c(n−1). Then T(n) = T(n−1)+d ≤ c(n−1)+d = cn−c+d ≤ cn whenever c ≥ d.
→
4
Conclusion
Choosing c=d makes the last step hold. T(n)=O(n) - matching the 4-frame trace hand-counted for factorial(4) above.
✓
ConclusionT(n) = T(n−1) + d solves to T(n) = O(n).
💡
Key takeawaySubstitution proves a guess by induction - base case, then an inductive step that carries it for every larger n.
Department of Intelligent Computing
Substitution method · worked example 2 of 2 (harder)

A New Recurrence: ,

Same method, a concrete constant this time - and a limit on what substitution can actually do for you.
GoalFind a constant c that makes the inductive step hold, then see what substitution cannot supply.
1
Guess
T(n) = O(n), i.e. T(n) ≤ cn for n ≥ n0.
→
2
Inductive step
T(n) = T(n−1)+3 ≤ c(n−1)+3 = cn−c+3 ≤ cn exactly when c ≥ 3. Any c ≥ 3 works - choose c=3.
→
3
Base case
T(0)=1 ≤ c·n0 for a suitable n0 (e.g. n0=1, c=3: 1 ≤ 3, holds).
★
What substitution can't do
The method only verifies a guess - it never tells you what to guess. That's exactly why the recursion-tree method, next, is useful even when substitution is available: it can suggest a guess to check.
✓
Conclusionc=3, n0=1 proves T(n) = T(n−1)+3, T(0)=1 solves to T(n) = O(n).
💡
Key takeawaySubstitution proves; it doesn't propose. A recursion tree, next, can propose the guess in the first place.
Department of Intelligent Computing
Recursion-tree method · worked example 1 of 2 (moderate)

Drawing the Tree:

Instead of guessing, draw every call and sum the work level by level.
GoalSum this divide-and-conquer recurrence level by level to a closed form.
1
Level 0
1 subproblem, size n. Cost: n.
→
2
Level 1
2 subproblems, size n/2 each. Cost: 2·(n/2) = n.
→
3
Level 2 and on
4 subproblems, size n/4: cost 4·(n/4) = n. The pattern holds - every level costs about n.
→
4
Total
log₂n + 1 levels, each costing about n: T(n) = n(log₂n + 1) = O(n log n) - reused, unpreviewed, starting Week 6.
✓
ConclusionT(n) = 2T(n/2) + O(n) solves to T(n) = O(n log n).
💡
Key takeawayEvery level here costs the same - that flat pattern is the signature of Master Theorem Case 2, next.
Department of Intelligent Computing
Recursion-tree method · worked example 2 of 2 (harder)

A Different Split Factor:

Same method, but the branching factor now outpaces the halving of size.
GoalShow what happens when each level costs more than the last.
1
Level 0
1 subproblem, size n. Cost: n.
→
2
Levels 1-2
Level 1: 3 subproblems, size n/2, cost 3·(n/2) = 1.5n. Level 2: 9 subproblems, size n/4, cost 9·(n/4) = 2.25n. Costs are growing, not flat.
→
3
Bottom level
log₂n levels down: 3log₂n = nlog₂3 ≈ n1.585 leaves, each O(1). The sum is dominated by this bottom level.
★
Result
T(n) = Θ(nlog₂3) ≈ Θ(n1.585) - Master Theorem Case 1 (many small subproblems dominate), unlike the last example's Case 2.
✓
ConclusionT(n) = 3T(n/2) + n solves to T(n) = Θ(nlog₂3).
💡
Key takeawayWhen per-level cost grows instead of staying flat, the leaves - not the top - dominate the sum.
Department of Intelligent Computing

A First Look: the Master Theorem

Intuition only today - the real conditions and proof wait for Week 9.

For , compare against :

Case When Intuition Result
1 grows slower the many small subproblems (leaves) dominate
2 grows about the same every level costs about the same
3 grows faster the split itself dominates

Merge sort () lands in Case 2 - matching
the recursion-tree result exactly.
() lands in Case 1, since grows
slower than - matching the tree above too.

Department of Intelligent Computing
Master Theorem · worked example

Two More Recurrences, Classified

Same table as above, applied cold to two new recurrences.
GoalClassify each recurrence's case, then read off its closed form.
1
T(n) = 4T(n/2) + n²
nlog₂4 = n². f(n) = n² grows about the same → Case 2: T(n) = Θ(n² log n).
2
T(n) = T(n/2) + 1
nlog₂1 = n⁰ = 1. f(n) = 1 grows about the same → Case 2: T(n) = Θ(log n) - binary search's cost, previewed for Week 7.
★
Same signature as merge sort
Both land in Case 2, the same case as T(n) = 2T(n/2) + O(n) above - every level costing about the same is the recurring signature of Case 2.
✓
ConclusionBoth recurrences classify as Case 2, giving Θ(n² log n) and Θ(log n) respectively.
💡
Key takeawayClassifying a recurrence is a three-way comparison: does f(n) grow slower than, the same as, or faster than nlog_b a?
Department of Intelligent Computing

CampusNav: The Multi-Stop Tour, Recursively

Back to the intern's feature. Now let's actually measure it.

"Visit the library, then the gym, then a friend's dorm":

  • Total time = the first leg, plus the recursive time for the rest - a base case (no stops left) and a recursive case, exactly as defined a few slides ago.
  • Its recurrence is - the exact same shape as factorial. This part of the feature is cheap and well-behaved.
Department of Intelligent Computing
CampusNav · the feature that froze

Counting All Tour Orders - the Trap

"Show me every possible order" branches at every remaining stop.
GoalShow why this feature explodes, when `tourTime` above didn't.
1
The formula
allOrders(remaining) = sum, over every next stop in remaining, of allOrders(remaining minus next stop). allOrders(∅) = 1.
→
2
3 stops
The recursion tree branches 3 → 2 → 1, giving 3! = 6 leaves - the demo's 6 orders.
★
Why it explodes
Each extra stop multiplies, not adds, to the tree. `allOrders` is slow because it genuinely branches into more distinct choices at every level - there is no repeated work to eliminate, only an unavoidably large number of true orderings.
✓
ConclusionThe recursion itself isn't the problem - `tourTime` above was just as recursive and stayed cheap. `allOrders` explodes because it branches into every remaining stop at every level.
💡
Key takeawayWeek 11's Dynamic Programming stops re-deriving the same partial answers - but that fix only helps when answers actually repeat, which is exactly what the next example checks.
Department of Intelligent Computing

The fib(5) Call Tree

Naive recursive `fib(n) = fib(n-1) + fib(n-2)`, drawn out - a different disease from `allOrders`.
fib(5)
├─ fib(4)
│   ├─ fib(3)
│   │   ├─ fib(2)
│   │   │   ├─ fib(1)  [base]
│   │   │   └─ fib(0)  [base]
│   │   └─ fib(1)  [base]
│   └─ fib(2)
│       ├─ fib(1)  [base]
│       └─ fib(0)  [base]
└─ fib(3)
    ├─ fib(2)
    │   ├─ fib(1)  [base]
    │   └─ fib(0)  [base]
    └─ fib(1)  [base]
Department of Intelligent Computing
Naive Fibonacci · a different disease

The Waste, Counted

Same tree as the last slide. Now count the repeats, and compare to `allOrders`.
GoalShow that "slow and recursive" is not one disease - and that only one of the two responds to the same cure.
1
Count the repeats
`fib(3)` computed twice, `fib(2)` three times, `fib(1)` five times - 15 total calls to answer one number a loop reaches in 5 additions.
→
2
A different disease than `allOrders`
Nothing here branches into ever-more choices - the same two smaller subproblems just get asked for, over and over. Week 11 names this overlapping subproblems.
★
Would an iterative rewrite fix it?
Yes for `fib` - storing each `fib(k)` once turns 15 calls into 6, an O(n) pass (exactly Week 11's dynamic programming). No for `allOrders` - there is no repeated subproblem to cache; every one of the n! orderings is genuinely distinct, so an iterative rewrite still does n! work.
✓
Conclusion`allOrders` and naive `fib` are both exponential-ish, but for structurally different reasons - branching vs. redundant recomputation.
💡
Key takeawayDiagnosing which disease you have determines whether memoization (Week 11) can even help.
Department of Intelligent Computing

Common Mistakes

  • "Recursion is always less efficient than iteration." Tempting because every recursive call has function-call overhead - but the real cost driver is how many calls happen and whether they repeat work. factorial and tourTime are just as cheap, , as their iterative twins; allOrders is expensive because of its branching shape, not because it recurses.
  • "The base case is just where you stop." Tempting because it feels like a technicality. It is actually what bounds the entire recursion tree's depth (and, once a method branches, its size) - miss it, or shrink the wrong thing, and the tree never stops growing.
Department of Intelligent Computing

Key Words Today

  • Divide-and-conquer: split a problem in half, solve each half recursively, combine - previewed today, formalized Week 9.
  • Memoization: storing a recursive call's answer so it's never recomputed - the fix allOrders is missing, coming Week 11.
  • Stack overflow: a crash caused by too many "waiting" call-stack frames at once - recursion's real-world failure mode.
  • Closed-form solution: a formula for with no recurrence left in it - what substitution and the recursion tree both produce.
Department of Intelligent Computing

Recursion Shows Up Everywhere

CampusNav is one example. This shape is everywhere.
File system folders
Nested JSON / HTML
Tree & graph traversal
Divide-and-conquer
Backtracking search
Parsing expressions

Any structure that contains smaller versions of itself - a folder
containing folders, a sentence containing clauses, a tree containing
subtrees - is naturally described recursively.

Department of Intelligent Computing

Why This Also Matters Beyond CampusNav

Security-relevant, not just academic: real parsers and interpreters have crashed in production from deeply nested or adversarially crafted input hitting an unbounded recursive case - attackers have used this deliberately. Knowing that a base case bounds depth is not a technicality; it's a correctness and safety property.

Every advanced course after this one - compilers, databases, systems -
assumes you can look at a self-referential structure and reason
about it without flinching.

Department of Intelligent Computing

What Today's Toolkit Cannot Do

We can now trace a recursive call stack frame by frame, write down the recurrence that describes its cost, and solve that recurrence with substitution, a recursion tree, or an intuitive read of the Master Theorem. But none of that gives CampusNav a fast algorithm - right now, "find a room" and "put the directory in order" still mean scanning an unsorted list and hoping. We have a real toolkit for measuring cost, but still just an unsorted array and brute force for actually reducing it.
Department of Intelligent Computing

Next Week

Week 4 leaves CampusNav with an unsorted room directory and nothing
but brute-force scans
to search it. Week 5, Basic Sorting,
addresses it: the first real algorithms for putting that directory in
order, traced and proven correct by hand.

Department of Intelligent Computing

Where This Week Lives in CLRS

This week's ideas, mapped to the textbook.
This week's topic CLRS 4th ed
Substitution method §4.3
Recursion-tree method §4.4
Master method §4.5

If you want to go deeper: §4.6-4.7 cover the continuous Master
theorem and Akra-Bazzi recurrences, for shapes that don't fit the
standard Master method - useful once you meet a recurrence that
doesn't cleanly match one of today's three cases. (§4.1-4.2, matrix
multiplication and Strassen's algorithm, are not this week's
reading - they return in Week 9.)

Department of Intelligent Computing

Summary

  • A recursive algorithm is defined by a base case (where it stops) and a recursive case (where it calls itself on something smaller) - miss the base case and the recursion never stops.
  • Tracing factorial(4)'s call stack shows exactly what's "waiting" at each depth, and why the base case bounds that depth.
  • A recursive algorithm's cost is a recurrence relation; substitution (guess + prove by induction) and the recursion tree (sum level by level) both solve one, and the Master Theorem previews a shortcut for the divide-and-conquer shape (full rigor Week 9).
  • Recursion itself isn't slow - tourTime and factorial are both ; allOrders explodes from branching, not recursion, and that is exactly what Week 11's DP will fix.
Department of Intelligent Computing

Summary, Continued

  • New: Week 4 Check - a short graded exercise on call-stack tracing, recurrences, and the recursion-tree method, released now, due before Week 5 begins (see materials/assignments/week04-check.html).
  • Reading: CLRS 4th ed, §4.3-4.5 - no exercises due.
  • Prepare: think about how you'd put a shuffled stack of 10 index cards in order by hand. Bring your method to Week 5.
Department of Intelligent Computing

Thank You

Department of Intelligent Computing

SLOT 1: Title

notes: Open with an everyday example of explaining a rule by using the rule itself (e.g. "ask your older sibling, and if they don't know, ask THEIR older sibling"). That self-reference is today's whole topic, long before we call it "recursion."

SLOT 2: Where we are

notes: Point at Week 4. Say: "Last week gave us a ruler for growth rates. This week, we point that ruler at algorithms that call themselves."

REWRITTEN: was a discussion warm-up; now teacher-delivered narration that resolves directly

SLOT 3: Recap + open wound

NEW: Key Words Today, session 1

notes: Read each term aloud once. Say these four words are today's whole vocabulary, formalized properly in a few minutes.

SLOT 4: The pain (Act 1 / MOTIVATE), zero jargon

notes: Do not say "recursion," "recurrence," or "exponential" yet. Let the class feel the freeze first.

notes: Pause after the third bar. Say: "This is not a bug - it is structural."

SLOT 5: Cost of not knowing, split: the app-level cost here, the industry angle next

NEW: continuation - the industry angle, split out of the same slide

SLOT 6: Driving question

SLOT 7: Learning outcomes

SLOT 8: Origin, split into two

NEW: continuation of Origin

NEW: continuation - the expansion trace, split out of the same slide

SLOT 9: Core concept

NEW: continuation of the core concept, split out of the same slide

NEW: Key Words Today, session 2

notes: Read each term aloud. Say these four words return, formalized further, later this session and in Week 9.

Act 3 / BUILD: recursion vs. iteration

NEW: dense worked example, factorial(4) call-stack trace. Merges the old "Going Down" + "Going Up" slides, folds the "frames waiting" Check Yourself content.

MERGED: idea+pseudocode and the condensed trace onto one slide

Act 3 / BUILD: recurrence relations

NEW: continuation - the divide-in-half shape, split out of the same slide

NEW: induction primer, before the substitution method

NEW: dense worked example, substitution method, moderate tier

NEW: dense worked example, substitution method, harder tier. Reuses the deck's exact existing Check-Yourself recurrence.

NEW: dense worked example, recursion-tree method, moderate tier (Master Theorem Case 2 shape)

NEW: dense worked example, recursion-tree method, harder tier (Master Theorem Case 1 shape)

NEW: dense worked example, applying the Master Theorem. Folds the old Check Yourself pair, reusing its exact recurrences.

Act 3 / BUILD: CampusNav worked example, part 1

SLOT N-2: Worked example. Dense conversion of the feature that actually froze.

NEW: naive Fibonacci call tree, makes "re-deriving the same partial answers" concrete

NEW: dense worked example, the waste counted. Folds the old Check Yourself "Two Different Diseases" pair.

SLOT N-1: Common mistakes, merged into one slide

NEW: Key Words Today, session 3

notes: Read each term aloud. Say: "Memoization is the one word to remember - it's exactly what Week 11 adds to fix today's exploding tree."

SLOT N+1: Limits (Act 4 / CLOSE), becomes Week 5 slot 4

SLOT N+2: Bridge

NEW: "Where This Week Lives in CLRS" reference slide, immediately before Summary

SLOT N+3: Summary

SPLIT for overflow

SLOT N+4: Thank You