6 documents
Bubble sort
Teach bubble sort to students and junior engineers through short, visual-first lessons.
Lesson 1: One pass, by hand
The single idea learners must own before anything else: a pass carries the largest element to the end.
Lesson 2: The invariant
One sentence that makes bubble sort obviously correct, and answers "why n - 1 passes".
Lesson 3: Full algorithm and early exit
Assemble the passes, then add the one flag that gives an O(n) best case.
Lesson 4: Counting the cost
Derive n(n - 1)/2 on the board, then show learners what quadratic feels like.
Lesson 5: Stability and insertion sort
Two questions every sharp learner asks: "does it keep ties in order?" and "what should I use instead?"
Lesson 6: Teach it
Capstone. A three-minute script, one diagram, a demo, and the questions learners will ask.