A textbook
Modern Algorithm Design
Design algorithms from primitives, and know what to demand of them.
Modern Algorithm Design teaches you to design algorithms and data structures, not to memorize them. Its claim is that much of algorithm design can be understood through a small set of recurring ideas, called primitives, and the ways they compose. Machines can now search design spaces at a scale no person can, so the book trains the skill that stays with you: knowing what to ask for, what must hold, and how an answer can fail.

What it is
A textbook, online at modernalgorithmdesign.com. Two chapters are published so far: Contracts and cost models and Search. Every primitive comes with its label: what it assumes, what it costs, and how it fails.
Who it is for
Anyone who wants to design with algorithms, whether they build the design themselves, ask an AI to build it, or work with an AI to frame the problem. The chapters hand you a problem before they hand you its solution. Some boxes ask you to put the AI away and work the problem out alone, because an ability you have never had to use may not be yours.
What makes it different
A primitive is taught by what it buys and where it breaks, so you can compose it with others and still predict the result. Vocabulary is treated as the point: in the age of AI, a precise word is also a precise specification.
Code you can check
All the book's code is public at github.com/mbrcic/algodesign. Each structure is written three times: in Python, the version the book prints; in Rust, the fast one; and in Lean, where what the structure promises is stated and proved. Every listing the book prints is run against this library whenever the book is built, and a mismatch fails the build.
More
Use it in a course, or tell me what breaks.
Corrections and questions from readers are how the book gets better.
Get in touchLast updated .