15 of 56 topics ready
Data Structures and Algorithms A hands-on handbook that takes you from counting steps and linked lists to balanced trees, graphs, dynamic programming and the limits of computation. Every topic is explained in plain prose, traced step by step, built from scratch in Python and checked against the libraries used in practice.
9 parts
15 topics ready
56 topics planned
103 runnable examples
Nine parts, one path
Start with the core, then branch out by interest.
Foundations How to state what an algorithm must do, prove that it does it and count what it costs: abstract data types, proofs and invariants, the mathematical toolkit, asymptotic notation, recursion, recurrences, amortized analysis and the probability that randomized methods rely on.
2 of 8 topics ready Linear structures Sequences stored one after another: contiguous arrays and the dynamic arrays behind Python lists, linked lists in all their variants, stacks and queues.
2 of 4 topics ready Searching and sorting Finding an item and putting items in order, the two problems that teach most of algorithm analysis: binary search and its traps, the elementary sorts, merge sort and quicksort, the comparison lower bound, sorting in linear time, selection, and how real libraries sort.
2 of 7 topics ready Trees Hierarchies and the search trees built on them: traversals and expression trees, threaded trees, binary search trees, the balanced families (AVL, red-black, splay, B-trees), heaps, augmented trees and the range-query trees used in competitive and production code.
4 of 11 topics ready Hashing Finding items in constant expected time: hash functions, collision resolution by chaining and open addressing, how production hash tables are engineered and attacked, and the probabilistic structures that trade exactness for space.
1 of 3 topics ready Graphs Networks of things and the classic algorithms on them: representations, breadth-first and depth-first search, topological order, connectivity, union-find, minimum spanning trees, shortest paths and maximum flow.
2 of 9 topics ready Algorithm design The general strategies behind most algorithms: divide and conquer, greedy choice with its exchange arguments, dynamic programming, backtracking with branch and bound, number theory and randomization.
1 of 8 topics ready Strings Searching text and indexing it: naive matching, Rabin-Karp, Knuth-Morris-Pratt, Boyer-Moore, tries and suffix arrays, each traced character by character and compared with what Python's own string search does.
1 of 4 topics ready Complexity What efficient algorithms cannot do: decision problems, polynomial-time reductions and NP-completeness, then approximation algorithms that come with a guarantee when exact answers are out of reach.
0 of 2 topics ready
Inside every topic
Every topic has the same shape, so once you know one you can find your way around all of them.
Readable theory Plain prose, with formulas and diagrams drawn as images. From-scratch code A package of small modules, one idea per file, fully commented. Runnable examples Short scripts, each showing one idea or one library comparison. A sample project An end-to-end command line project on a realistic task. A guided notebook A tour that imports the package and shows results inline. Tests Checks for every worked example and every property the page claims.
Learning path
Start with the core and branch out by interest. Each part lists what it builds on.
Getting started
You need Python 3.11 or newer. The repository installs as one package, so every example and project script can import the topic it belongs to. The data structures themselves use only the standard library; plotting, notebooks and the library comparisons need the dependency groups in pyproject.toml, and each topic names the groups it needs near the top of its README.
With uv:
uv sync --group dev --group graphs
uv run python trees/heaps-and-priority-queues/examples/worked_example.py
uv run pytest
With pip 25.1 or newer:
python -m venv .venv
source .venv/bin/activate
pip install -e . --group dev --group graphs
python trees/heaps-and-priority-queues/examples/worked_example.py
pytest