Week 2: Algorithm Concepts

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

Before We Start: Could a Computer Actually Run This?

Three ways to phrase "find room 703." Only one of them is actually an algorithm.

Three instructions for finding room 703 in Building A:

  • A: "Walk to Building A, take the stairs or elevator to floor 7, and go to room 703."
  • B: "Look around until you find it."
  • C: "Keep improving your guess about where it is until it feels right."
Department of Intelligent Computing

Only One of These Is Actually an Algorithm

Same three instructions. Here's why only one of them qualifies.

Only A could be handed to a computer, or to two different
classmates, and produce the exact same result every time. B and
C both sound reasonable in conversation - that's exactly the trap.
B never says what "look around" means as an executable step (an
effectiveness problem); C never states a condition for when to
stop (a finiteness problem, on top of the same effectiveness gap).
Today's five properties are precisely how we tell A apart from B and
C, instead of just feeling the difference.

Department of Intelligent Computing

Last Week, This Week

  • Last week delivered: the course contract - grading, policy, schedule - plus a first taste of the question this whole course answers.
  • Last week left broken: we still have no rigorous way to check whether a written-down procedure even qualifies as a real algorithm. "Look around until you find it" still sounded like a perfectly reasonable instruction.
Department of Intelligent Computing

Key Words Today

  • Property: one required condition a procedure must satisfy to count as a real algorithm - today's whole topic is five of them.
  • Ambiguous: allowing more than one reasonable interpretation - exactly what a real algorithm is never allowed to be.
  • Spec (specification): a precise statement of what problem an algorithm solves - what counts as valid input, and what output is required.
  • Pseudocode: a structured, language-independent way of writing algorithm steps precisely, without full programming-language syntax.
Department of Intelligent Computing

Two Developers, One Instruction

CampusNav's team writes down "find room X" as a spec: "Look around
until you find it, and ask someone if you're stuck." Both developers
say, honestly, that they implemented the spec - and ship completely
different builds for the same instruction.

Department of Intelligent Computing

Two Different Builds, Side by Side

Same spec. Here's what each developer actually shipped.

Developer A's build

  • Displays a static campus photo
  • User visually scans the image
  • No fallback if the photo is unclear

Developer B's build

  • Pops up "Ask a nearby person"
  • No guidance on who to ask or what to say
  • No fallback if no one is nearby
Department of Intelligent Computing

Two Different Apps, Same Instruction: Why?

Same spec, two builds - what actually went wrong.

In the demo, nobody in the room can say which one is wrong - the
instruction never pinned down what "look around" or "ask someone"
actually means as steps a program executes.

Department of Intelligent Computing

What This Actually Costs

  • Two "implementations of the same algorithm" behave differently - a bug report against one team's build may not even reproduce on the other's.
  • Without fixed rules to check a procedure against, code review is just opinion: "this feels vague" instead of "this precisely violates property X."
  • Nobody can even agree on what the "correct" behavior is, because the instruction never defined one.
In industry: ambiguous specifications are one of the most common root causes of the gap between what a team meant to build and what got shipped. Technical interviews grade your stated algorithm on exactly this: is it precise enough that two different graders, tracing it by hand, would reach the identical conclusion?
Department of Intelligent Computing

This Week's Question

"What makes a written set of steps precise enough that anyone - or any computer - must run it exactly the same way?"
Department of Intelligent Computing

By the End of This Week, You Can

  1. State and check the five properties every real algorithm must satisfy: finiteness, definiteness, input, output, effectiveness.
  2. Distinguish an algorithm from a program that implements it.
  3. Write pseudocode, and read a flowchart, precise enough that a vague instruction is disqualified on sight.
  4. Given a broken "algorithm," identify exactly which property it violates and why.
Department of Intelligent Computing

Precision Is Not New (1)

You just felt the mess. Now: who fixed it, and how long ago?
  • Euclid's algorithm for the greatest common divisor (~300 BCE) is the oldest algorithm still taught today - a precise, step-by-step procedure, written down long before "computer" meant a machine.
  • In 1936, Alan Turing and Alonzo Church, working independently, formalized exactly what "a step-by-step procedure a machine can follow" even means - the moment "algorithm" stopped being an informal word.
Department of Intelligent Computing

Precision Is Not New (2)

One more name, then the rulebook itself, next slide.
  • Donald Knuth, in The Art of Computer Programming (1968), wrote down the five properties on the next slide precisely because, without them, two people who both claimed to have "an algorithm" could be describing completely different things - exactly like our two CampusNav developers.
Every field that depends on precise procedures - law, medicine, cooking, computing - eventually invents its own version of "this instruction is too vague to follow reliably." Computing's version is the five properties.
Department of Intelligent Computing

Algorithm: The Five Required Properties

This is the rulebook. Every algorithm this semester gets checked against all five (CLRS - Cormen, Leiserson, Rivest & Stein's Introduction to Algorithms, 4th ed, Ch 1).
  1. Finiteness - must terminate after a finite number of steps, for every valid input.
  2. Definiteness - every step must be precisely and unambiguously specified; no room for interpretation.
  3. Input - zero or more well-defined values, from a specified set, supplied before execution begins.
  4. Output - one or more well-defined values, with a specified relationship to the input.
  5. Effectiveness - every step must be basic enough to be carried out exactly, in principle by a person with pencil and paper, in finite time.

A procedure that fails even one of these is not an algorithm - it's a suggestion.

Department of Intelligent Computing

Key Words Today

  • Finiteness: must halt after a finite number of steps, for every valid input - provably, not just "it stopped when I ran it."
  • Definiteness: every step has exactly one meaning; no step can be read two different ways.
  • Effectiveness: every step must be simple enough to actually carry out exactly, in finite time - no step may rely on a "feeling."
  • Well-defined input/output: the exact set of legal values, stated precisely - including what happens on an input with no good answer.
Department of Intelligent Computing

How We'll Write Pseudocode This Semester

Definiteness and effectiveness, as house rules.
1
One primitive operation per line - no line does two things at once.
2
Every loop states its exact bound: for i = 1 to n, not "repeat a while."
3
Every array index range is explicit - indices run 0 to length(A) - 1, stated, not assumed.
4
No verb like "check," "look," or "handle" appears without saying exactly what operation it performs.
5
Every function names its input and its output on the signature line: NAME(param1, param2).
Department of Intelligent Computing

Pseudocode Conventions, Continued

Five more rules before we can read anything on the next few slides.
6
= means assignment (store a value); == and != mean comparison (a true/false test) - never confuse them: x = 5 sets x to 5, x == 5 asks whether it already is.
7
if condition: followed by an indented block is everything that runs when the condition is true - indentation alone marks a block's extent, no closing keyword needed.
8
while condition: repeats its indented block as long as the condition holds. Use while when the number of passes isn't known in advance; use for when it is.
9
return value ends the function immediately and hands value back to whoever called it.
10
mod (modulo) is the remainder after division: 17 mod 5 = 2, because $17 = 3 \times 5 + 2$. We lean on it constantly starting with GCD, a few slides from here.
Department of Intelligent Computing

Pseudocode Conventions, Continued (2)

The rest of this semester's vocabulary, in one more pass.
11
swap A[i] and A[j] exchanges their two values. What happens under the hood (usually a temporary variable) never matters for reading pseudocode - only that both values trade places.
12
Boolean conditions combine with and, or, not. and/or evaluate left to right, so i < length(A) and A[i] == target is safe - the length check runs first and can block the unsafe index read before it happens.
13
break exits the nearest enclosing loop immediately, skipping any remaining passes.
14
A[lo..hi] means the subarray from index lo to index hi, inclusive of both ends.
15
A record (or struct) groups named fields together; someRecord.field reads one of them - directory[i].room, a few slides from here, is exactly this.
Department of Intelligent Computing

CLRS's Own Pseudocode Style

Our house style isn't the only one. Here's the textbook's (CLRS 4th ed, §2.1-2.2).

Every algorithm in CLRS is written in a slightly different dialect of
the same idea:

  • 1-indexed arrays: CLRS arrays run A[1..n], not A[0..n-1] -
    the very first thing to translate when moving between the book and
    our own pseudocode.
  • Numbered lines: every statement gets its own line number, so a
    proof (like a loop invariant) can say "after line 5" precisely.
  • // comments: a trailing note that isn't executed - the same
    role as a comment in real code.
  • Same underlying rules as ours: definiteness and effectiveness still
    apply - only the surface notation differs.
Department of Intelligent Computing

Worked Example: INSERTION-SORT, CLRS-Style

Not today's content - just today's notation, on the algorithm you'll meet properly in Week 5.
INSERTION-SORT(A, n)
1   for i = 2 to n
2       key = A[i]
3       // Insert A[i] into the sorted subarray A[1..i-1].
4       j = i - 1
5       while j > 0 and A[j] > key
6           A[j + 1] = A[j]
7           j = j - 1
8       A[j + 1] = key

Notice A[i] starts at index 2 (1-indexed), and each line is
numbered. Same five properties apply to this procedure as to any
other - we are not analyzing its cost yet, only reading its shape.

Department of Intelligent Computing

Two Styles, One Idea

`FIND_ROOM` and `INSERTION-SORT`, compared.

FIND_ROOM (our house style) and INSERTION-SORT (CLRS style) use
different indexing conventions - different notation, not a
different algorithm
, exactly the algorithm/program distinction one
level up: the same idea can be written down two ways, as long as each
is precise.

Department of Intelligent Computing

Flowchart Conventions

Same rules, drawn instead of written.
Oval = Start / End
Rectangle = Process step
Diamond = Decision (yes/no branch)
Arrow = Flow of control
  • Exactly one Start oval, and every path must reach an End oval - draw one and you're checking finiteness visually.
  • Every Diamond must have exactly two labeled exits (e.g. "yes" / "no") - an unlabeled or missing branch is a definiteness violation, drawn: whoever reads the flowchart would not know what to do in the unlabeled case, so two readers could build two different behaviors from the same diagram.
  • Pseudocode and flowcharts describe the same algorithm two ways; FIND_ROOM (a few slides ahead) converts cleanly into one Diamond (directory[i].room == target), one Rectangle (advance i), one Start oval, and two End ovals (found / NOT_FOUND).
Department of Intelligent Computing

What Is a GCD?

Before the algorithm: what are we even computing?

The greatest common divisor of two whole numbers is the largest whole number that divides both of them with no remainder.

Department of Intelligent Computing

GCD(12, 18), the Slow Way

One correct method, before we meet the fast one.

List every divisor:

  • Divisors of 12: 1, 2, 3, 4, 6, 12
  • Divisors of 18: 1, 2, 3, 6, 9, 18
  • Common to both: 1, 2, 3, 6
  • Greatest of those: 6 - so GCD(12, 18) = 6.

That works for small numbers, but listing every divisor of two 12-digit numbers is hopeless. Euclid's algorithm gets the same answer without ever listing a single divisor - the next two slides show how, drawn and then written.

Department of Intelligent Computing

Flowchart: Euclid's GCD

The pseudocode on the next slide, drawn instead of written - same algorithm, converted.
GCD(a, b) b != 0? yes r = a mod b a = b b = r no return a
Same three lines as the loop body in the pseudocode next: r = a mod b, then a = b, then b = r - the diamond re-checks after each pass around the loop.
Department of Intelligent Computing

Euclid's GCD: Idea and Pseudocode

A clean, classic case before we return to CampusNav's messier one (CLRS 4th ed, §31.2).
GCD(a, b):
    while b != 0:
        r = a mod b
        a = b
        b = r
    return a
  • Input: two well-defined positive integers, a and b.
  • Output: a single well-defined integer, their greatest common divisor.
  • Definiteness: mod, assignment, and comparison are each precisely defined operations - no step is open to interpretation.
  • Effectiveness: mod, assignment, and != are all basic operations any of us could execute by hand.
Department of Intelligent Computing
Euclid's GCD · worked example 1 of 3 (simple)

The Fastest Case: GCD(8, 4)

The smallest case that still runs the loop - and stops after just one pass.
GoalTrace GCD(8, 4) and see finiteness hold in the fewest possible steps.
1
Start
a=8, b=4. b != 0, so the loop body runs.
→
2
One step
r = 8 mod 4 = 0. a = 4, b = 0.
→
3
Result
b = 0 now, so the loop stops immediately. Return a = 4.
✓
ConclusionGCD(8, 4) = 4 in a single iteration.
💡
Key takeawayEven the "instant" case is governed by the exact same shrinking-`b` rule that guarantees every case eventually stops.
Department of Intelligent Computing
Euclid's GCD · worked example 2 of 3 (moderate)

A Full Trace: GCD(48, 18)

Three passes this time - watch `b` shrink toward 0 every step.
GoalTrace GCD(48, 18) completely, one iteration per card.
1
Step 1
a=48, b=18: r = 48 mod 18 = 12. a=18, b=12.
→
2
Step 2
a=18, b=12: r = 18 mod 12 = 6. a=12, b=6.
→
3
Step 3
a=12, b=6: r = 12 mod 6 = 0. a=6, b=0. b=0, loop stops.
→
4
Result
Return a = 6. Matches the divisor-listing check from a few slides back.
✓
ConclusionGCD(48, 18) = 6 after 3 iterations - no divisor list needed.
💡
Key takeawayThree steps instead of one - shrinking `b` still guarantees termination, it just takes more passes.
Department of Intelligent Computing
Euclid's GCD · worked example 3 of 3 (harder)

The Slow Case: GCD(89, 55), and Why It Still Stops

Consecutive Fibonacci numbers are the worst case for this algorithm - let's see why it still terminates.
GoalTrace the slowest realistic case, then prove termination in general, not just for this pair.
1
Setup
GCD(89, 55) - consecutive Fibonacci numbers. Compare to GCD(48, 18)'s 3 steps.
→
2
First 3 steps
r=89 mod 55=34; r=55 mod 34=21; r=34 mod 21=13 - three steps in, still not close to 0.
→
3
Six more steps
r=21 mod 13=8; r=13 mod 8=5; r=8 mod 5=3; r=5 mod 3=2; r=3 mod 2=1; r=2 mod 1=0. Nine steps total, versus three for GCD(48, 18) on similarly-sized inputs.
★
Why it must still stop
Every step's remainder r = a mod b is strictly less than b and never negative, so b strictly decreases toward 0 no matter how slowly - the argument that proves finiteness for every valid pair, not just the ones we happen to trace.
✓
ConclusionGCD(89, 55) = 1 after 9 steps - three times the work of GCD(48, 18), yet governed by the exact same guarantee.
💡
Key takeawayA trace only shows that one input stopped. Finiteness needs the general argument - `b` strictly decreases, bounded below by 0 - that covers every input, fast or slow.
Department of Intelligent Computing

One More Trap: "It Ran, So It Must Be Right"

GCD's proof was earned. Most code never gets that scrutiny - here's a bug hiding in plausible-looking code.

A student submits this attempt at "find the maximum value in a list."
It has never once produced a visibly wrong answer for its author - and
it still has a bug that fires on every single run.

MAX(A):
    m = A[0]
    for i = 1 to length(A):
        if A[i] > m:
            m = A[i]
    return m
Department of Intelligent Computing
MAX · finding the hidden bug

Where MAX Actually Breaks

Array indices run 0 to length(A) - 1. Here's exactly where the loop bound goes wrong.
GoalShow why passing tests never proves an algorithm correct.
1
The loop bound
The loop says `i = 1 to length(A)`, letting `i` reach `length(A)` - one past the last real element, out of bounds on every run.
→
2
What happens
Depending on the language, that read either crashes immediately, or silently returns whatever value sits in adjacent memory.
→
3
Why nobody noticed
That garbage value is often small enough that `A[i] > m` evaluates false - so the final answer still comes out right, by luck, not by correctness.
★
The real lesson
The bug fires every run; whether it's visible is luck, not design. Passing tests can show the presence of a bug hides - never its absence.
✓
ConclusionThe fix: the loop should run `i = 1 to length(A) - 1`. Looking definite and effective is not the same as being correct.
💡
Key takeaway"I tested it and it worked" is never proof of correctness - a silent, harmless-looking garbage read is still a bug.
Department of Intelligent Computing
Spotting broken "algorithms"

Two More Broken "Algorithms"

Neither of these could actually be run, or handed to a colleague, and produce one guaranteed behavior.
GoalName exactly which property each one violates, and why.
1
"While true: print the next prime number."
There is always a next prime - this procedure is designed to never stop and never produce a final output. Violates finiteness.
2
"Divide the budget fairly among the clubs."
"Fairly" has no fixed meaning - equal shares? by need? by past attendance? Every reader could execute a different procedure. Violates definiteness.
★
The pattern to notice
A procedure with no stopping condition breaks finiteness; a procedure with an undefined word ("fairly," "look around") breaks definiteness - the two most common ways a "sounds reasonable" instruction fails.
✓
ConclusionTwo failures, two different properties - one has no way to stop, the other has no fixed meaning.
💡
Key takeawayWhen a procedure "sounds reasonable" but isn't an algorithm, it's almost always missing a stopping rule or a fixed meaning for one of its words.
Department of Intelligent Computing

FIND_ROOM: Idea and Pseudocode

Same five checks. Now on the actual case study, not a clean textbook example.
FIND_ROOM(directory, target):
    for i = 0 to length(directory) - 1:
        if directory[i].room == target:
            return directory[i].location
    return NOT_FOUND
  • Input: a well-defined array directory of room records, and a well-defined string target.
  • Output: either a well-defined location, or the sentinel value NOT_FOUND.
  • Definiteness: == on target is a precise, single-meaning comparison.
  • Finiteness: loop bound length(directory) - 1 is fixed before the loop starts.
Department of Intelligent Computing
CampusNav · worked example 1 of 2

FIND_ROOM: All Five Properties, Checked

Everything from the last slide, verified against the full rulebook.
GoalShow `FIND_ROOM` satisfies every one of the five required properties.
1
Finiteness
Loop bound `length(directory) - 1` is a fixed, known number before the loop even starts - no proof needed like GCD's, just a stated bound.
2
Definiteness
`==` on `target` is a precise, single-meaning comparison - no "look around" left anywhere.
3
Input & Output
Input: well-defined array `directory` and string `target`. Output: a location, or the explicit sentinel `NOT_FOUND` - defining the "not found" case is part of a well-defined output, not an afterthought.
4
Effectiveness
Array indexing and string equality are basic, executable operations any of us could carry out by hand.
✓
ConclusionAll five properties check out - this is what "look around until you find it" had to become before it counted as an algorithm at all.
💡
Key takeawayA precise loop bound plus one precise comparison operator turned a vague sentence into a provable algorithm.
Department of Intelligent Computing
CampusNav · worked example 2 of 2

Designing the "Not Found" Case

A well-defined output has to cover every input - including the one with no "real" answer.
GoalShow why the sentinel value is part of the spec, not an afterthought.
1
Why `NOT_FOUND` counts
Output only counts as well-defined if every valid input has a specified result, including "the room isn't in the directory." A version that silently did nothing, or crashed, would leave output undefined for that input.
→
2
Alternative: return -1
A rewritten `FIND_ROOM` returning `-1` instead of `NOT_FOUND` is the same algorithm - both are a single, well-defined sentinel value for "not found."
★
The real risk
It would only become a problem if `-1` were also a valid room index somewhere else in the system - making the sentinel ambiguous with real data, a definiteness risk, not a difference in algorithm.
✓
Conclusion`NOT_FOUND` and `-1` are both valid designs for the same algorithm - the only real danger is a sentinel that could collide with real data.
💡
Key takeawayA well-defined output must cover every input, including the ones with no "real" answer.
Department of Intelligent Computing

Common Mistakes

  • Confusing "an algorithm" with "a program." An algorithm is the language-independent idea - the steps themselves; a program is one specific implementation of it, in one specific language. FIND_ROOM above could be written in Python, Java, or C and still be the same algorithm.
  • Assuming any loop that eventually stops is automatically finite. It's tempting because, in casual testing, the loop did stop. But finiteness requires a proof that covers every valid input - like GCD's "b strictly decreases and can't go below 0" argument - not just the one run you happened to try.
  • "It ran and gave the right answer, so it's correct." Exactly the MAX bug above: one passing run proves nothing about the inputs you didn't try.
Department of Intelligent Computing

Key Words Today

  • Flowchart: a diagram form of an algorithm, using standardized shapes (start/end, process, decision) instead of text.
  • Trace: running an algorithm by hand, step by step, on one specific input, to check what it actually does.
  • Algorithm vs. program: the algorithm is the language-independent idea; a program is one specific implementation of it, in one specific language.
  • Loop bound: the specific, checkable condition that guarantees a loop cannot run forever - what finiteness actually requires you to state, not assume.
Department of Intelligent Computing

Precision Pays Off Beyond CampusNav, Too

This isn't only about one app.

Every later week in this course assumes you can write and read
pseudocode this precisely: complexity analysis (Week 3) needs a fixed
procedure to count steps on; recursion (Week 4) needs a precise base
case; every correctness proof after that starts from a procedure
precise enough to reason about in the first place. Skip this week, and
every one of those gets harder.

The same five checks also show up outside this course, in the same words - search "algorithm properties" or "is this a valid algorithm" in any textbook or interview-prep guide.
Department of Intelligent Computing

What This Week's Rulebook Cannot Do

We can now write CampusNav's "find room X" as a real algorithm and check it against all five properties - precise input, precise output, provably finite, unambiguous, every step executable. But suppose a teammate proposes a completely different way to search the same directory, and it also passes all five checks. We have no rigorous way, yet, to say which precise algorithm is better - faster, more scalable as the directory grows - only that both are legitimate algorithms. "Precise" and "provably correct" are not the same claim as "efficient."
Department of Intelligent Computing

Next Week

Week 2 leaves comparing two precise, correct algorithms unsolved.
Week 3, Complexity Analysis, addresses it: Big-O notation, so we
can say precisely which algorithm is better, not just that both
qualify as real algorithms.

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
The five properties of an algorithm Ch 1
Pseudocode conventions (our house style vs. CLRS's) §2.1-2.2 (style reference - INSERTION-SORT isn't taught until Week 5)
Euclid's GCD §31.2

If you want to go deeper: §2.1's INSERTION-SORT is worth a first
read now for the notation alone; Chapter 31 (Number-Theoretic
Algorithms) covers what GCD is used for beyond this week, including
modular arithmetic and an early look at what becomes Week 9's fast
exponentiation.

Department of Intelligent Computing

Summary

  • Every real algorithm must satisfy five properties: finiteness, definiteness, input, output, effectiveness - fail one, and it's a suggestion, not an algorithm.
  • Pseudocode and flowchart conventions let us write and check these properties precisely, instead of just describing intent.
  • Algorithm ≠ program: the language-independent idea vs. one specific implementation of it.
  • Finiteness needs a proof (like GCD's shrinking b), not just one successful run.
  • New: Week 2 Check - a short graded exercise on the five properties, GCD, and FIND_ROOM, released now, due before Week 3 begins (see materials/assignments/week02-check.html).
  • Reading: CLRS 4th ed, Ch 1; §2.1-2.2 (pseudocode style reference); §31.2 (Euclid's GCD) - no exercises due, but read before Week 3.
  • Prepare: think of two different, both-correct ways you could search CampusNav's directory, and which one you guess is faster. Bring your reasoning to Week 3.
Department of Intelligent Computing

Thank You

Department of Intelligent Computing

SLOT 1: Title

notes: Remind the class of last week's "look around until you find it" line from the course-contract session. Say: "Today we get the actual rules for telling a real algorithm from a vague instruction that just sounds like one."

SLOT 2: Where we are

notes: Point at Week 2. Say: "Last week we felt why this course exists. This week we get the actual rulebook."

REWRITTEN: was a discussion warm-up; now teacher-delivered narration, also folds in the old end-of-deck Check Yourself Q1 (which property does "keep improving the guess" violate)

SPLIT for overflow: the resolution now gets its own slide

SLOT 3: Recap + open wound

NEW: Key Words Today, session 1

notes: Read each term aloud once. Say these four words get put to work in the next ten minutes.

SLOT 4: The pain (Act 1 / MOTIVATE), zero jargon. Split from the original combined pain+two-col slide: pain alone here, the two builds on the next slide.

notes: Do not say "definiteness" yet. Let the class feel the mess first; the two builds are on the next slide.

NEW: continuation - the two builds, side by side

notes: Do not say "definiteness" yet. Let the class feel the mess first.

SLOT 5: Cost of not knowing

SLOT 6: Driving question

SLOT 7: Learning outcomes

SLOT 8: Origin. Split into two: the older history here, Knuth's fix next.

NEW: continuation of Origin

SLOT 9: Core concept

NEW: Key Words Today, session 2

notes: Read each term aloud. Say: "Watch for these five ideas in everything for the rest of the hour."

Act 3 / BUILD: pseudocode and flowchart conventions

NEW: pseudocode conventions, continued (1 of 2)

NEW: pseudocode conventions, continued (2 of 2)

NEW: CLRS's own pseudocode conventions, as a second reference point (CLRS 4th ed, §2.1-2.2)

NEW: worked example in CLRS's own style, style reference only per SPINE.md (insertion sort content itself isn't taught until Week 5). Folds in the old Check Yourself pair on the two pseudocode styles.

SPLIT for overflow: the notation-vs-algorithm point now gets its own slide

MERGED: flowchart shapes + rules, folds in the old Check Yourself content on unlabeled diamonds and redrawing FIND_ROOM

What Is a GCD?, split: the definition alone here, the slow worked method next

NEW: continuation - the slow, brute-force method

Idea + pseudocode merged slide, matching the teacher-centric skeleton

NEW: dense worked example, GCD, simple tier

NEW: dense worked example, GCD, moderate tier (reuses the deck's existing verified 48,18 trace)

NEW: dense worked example, GCD, harder tier (reuses and completes the deck's existing 89,55 Fibonacci trace; folds the finiteness-proof content)

Rewritten: teacher-delivered exposition instead of a "find the bug" discussion prompt

NEW: dense worked example, MAX bug reveal. Folds the old "Where MAX Breaks" slide and the "Check Yourself: Tested vs. Proven" pair.

NEW: dense worked example, two more broken "algorithms". Folds the old Activity + Answers pair.

SLOT N-2: Worked example, idea + pseudocode

NEW: dense worked example, FIND_ROOM against all five properties

NEW: dense worked example, designing the sentinel value. Folds the old "Check Yourself: The Sentinel Value" pair.

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

NEW: Key Words Today, session 3

notes: Read each term aloud. Say: "These four, plus the five properties, are this week's whole vocabulary."

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

SLOT N+2: Bridge

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

SLOT N+3: Summary

SLOT N+4: Thank You