Lecture Notes — Lecture 15: Counting, Combinatorics, and Choice

Companion to the lecture plan and the worked examples. Read the Definitions before class, the Explanation after it; the practice questions and the lecture quiz close the loop.

Definitions

Explanation

Counting is problem solving without code. Start with the multiplication principle: if a task has stages with a and b choices, the whole task has a x b outcomes - outfits, PINs, routes. Factorials count arrangements: 5 students in a line, 5! = 120. Divide by the duplicated order when order should not matter: choosing 4 committee members from 10 is C(10,4) = 210, not 10 x 9 x 8 x 7, because each team was counted 4! times. Two habits carry the lecture: complement counting (count the forbidden, subtract from the total - usually far fewer cases) and the pigeonhole principle (with 13 students and 12 months, some month holds two birthdays). The advanced move is counting with constraints: glue the two students who refuse to separate, then count blocks. Every formula should be re-derived on a tiny case (n = 3) you can check by hand - formulas you cannot verify on paper you cannot trust in code.

Examples

The lecture's worked examples live in examples.md; the case studies this lecture builds on are worked in class from the projector. The case sequence with difficulties:

Common misconceptions

Summary and key takeaways

  1. Stages multiply, cases add - and 'at least one' often falls to complement counting.
  2. C(n, k) divides out the order that should not matter; permute only when order is real.
  3. Verify every formula on n = 3 by hand before trusting it at scale.
  4. Pigeonhole needs no code: 13 students, 12 months, someone shares.
  5. Constraints reshape counts - glue the pair that must stay together.

Practice questions

Where this leads

Next lecture: Review and Mini Challenge. The quiz below checks this lecture's essentials before we build on them.