Gale–Shapley Stable Matching

A stable matching always exists and is findable in O(n^2), but it's optimal for the proposing side. Mechanism design in twenty lines.

Mutual Exclusion Without Hardware Support

Peterson's algorithm and Lamport's bakery. Correct mutual exclusion from plain reads and writes, and why modern hardware still breaks it (see Memory models and...