Lecture 02 — Pseudocode as Precision

Position in the course

This is lecture 2 of 32. It belongs to the course arc described in the course outline and uses the standard interactive case method: display, attempt (5 minutes), discuss, reveal, name the technique.

Learning objectives

By the end of this lecture students can do all three under time pressure, which is what the four cases exercise.

Prerequisite knowledge

Before this lecture: Lecture 01 — Thinking in Problems

Assumed fluencies:

Preparation task: Re-read the two interpretation cases from lecture 1 (the fine formula and the coffee card).

Detailed topic outline

Core (mandatory):

  1. pseudocode grammar used all term (SEQUENCE/IF/WHILE/FOR)
  2. precision levels: vague → precise → testable
  3. state and assignment in pseudocode
  4. validating input in stages

Extension (optional enrichment):

  1. describing randomness and constraints
  2. pseudocode as communication, not decoration

Case sequence

CaseTitleDifficulty
cs-005Largest of ThreeBeginner
cs-006Password RulesFoundational
cs-007The Vending Machine ScriptIntermediate
cs-008Shuffling a PlaylistExpert

Display each case full-screen from the student page (cases cs-005–cs-008); instructor pages cs-005–cs-008 under case-studies/instructor/ hold the full solutions, reveal guides, and discussion prompts.

Timing plan (120 minutes)

MinutesSegment
0–10Framing: where this fits; recall of the previous lecture
10–30Case 1 (cs-005): 5-minute attempt, then discussion and reveal
30–50Case 2 (cs-006): same rhythm
50–70Case 3 (cs-007): same rhythm, harder case
70–75Break
75–100Case 4 (cs-008): same rhythm, hardest case
100–115Synthesis: name the techniques; misconceptions check
115–120Exit questions, homework, next-lecture preview

Timing flexes with the room: if a case ignites the class, let the discussion run and compress the synthesis; if the attempts stall, harvest partial attempts rather than extending the clock.

Worked examples

Instructor demonstration to open the lecture: Write largest-of-three (cs-005) twice: a vague one-line version and a precise testable version; let the class attack the vague one.

Classroom activities

#ActivityMinutesFormat and prompt
1Case Relay12Run activities/case-relay.md with cs-006: model → plan → code → test, each team inheriting the previous stage.
2Spot the ambiguity6Three pseudocode fragments are shown; teams find the sentence a compiler could not forgive.
3Hand-trace verification6Pairs exchange pseudocode and trace it on one input; sign off only if every variable is explained.

Board plan

Instructor explanation notes

Reading the room. Pseudocode is sold here as a contract: if a classmate cannot trace it, it is not finished. Resist letting strong students write Python 'to be helpful' — the delay is the point.

Running the reveal. Introduce the exact pseudocode grammar used all term (SEQUENCE, IF/ELSE, WHILE, FOR, functions) so later lectures can say 'as in lecture 2' instead of re-teaching.

Lecture focus. One sentence to repeat verbatim: Pseudocode is a contract another human can execute.

Common misconceptions

Each case's instructor page lists the specific wrong turn to expect; the reveal should address it by name.

Student practice exercises

Core:

  1. Write pseudocode for 'prompt until a valid 8-character student ID is entered' using the course grammar.
  2. Hand-trace your cs-006 pseudocode on two inputs, one failing each rule.
  3. Express cs-008's constraint 'no two consecutive tracks by the same artist' in one precise sentence plus one IF.

Enrichment (optional):

Formative assessment

Exit questions (choose one; answer on a card in 60 seconds):

  1. Name the three control shapes every pseudocode solution is built from. Expected: SEQUENCE, IF/ELSE selection, WHILE/FOR iteration
  1. What makes a pseudocode line 'testable'? Expected: it names variables and values precisely enough to hand-trace
  1. When is a state table required? Expected: whenever a later statement depends on more than the current input line

Cards are skimmed before the next lecture; three answers become the framing. Persistent wrong answers route students to the review stations of lecture 16 or to office hours.

Homework and preparation

Learning-outcome mapping

Differentiation