---
title: "Modern Algorithm Design"
author: "Mario Brcic"
author_url: "https://mariobrcic.com/about-me/"
canonical_url: "https://mariobrcic.com/modern-algorithm-design/"
summary: "A textbook by Mario Brcic on designing algorithms and data structures from reusable primitives, with Python, Rust and Lean code checked on every build."
license: "all-rights-reserved"
---
> *Canonical HTML version: [https://mariobrcic.com/modern-algorithm-design/](https://mariobrcic.com/modern-algorithm-design/). © Mario Brcic. All rights reserved.*

# Modern Algorithm Design

*Designing algorithms and data structures from reusable primitives.* By Mario Brcic.

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 https://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.

## 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 https://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.