Algorithms (Jeff Erickson)
Jeff Erickson's free algorithms textbook from the University of Illinois: recursion, backtracking, dynamic programming, greedy algorithms, graph search, spanning trees, shortest paths, flows and NP-hardness. It teaches you to design an algorithm by reasoning about the problem, which makes it the best free place to understand why backtracking and DP work rather than memorising them.
First edition, June 2019
jeffe.cs.illinois.edu · Oct 2026
13 (Introduction plus chapters 1 to 12)
jeffe.cs.illinois.edu · Oct 2026
CC BY 4.0 (textbook)
jeffe.cs.illinois.edu · Oct 2026
Book
Other
Jeff Erickson
Self-paced: about a week or two per chapter
Intermediate
Free
What the book is
Algorithms is a textbook by Jeff Erickson, a computer science professor at the University of Illinois Urbana-Champaign, written from the lecture notes of his algorithms courses there. The first edition appeared in June 2019. The author says the full-colour electronic version "will remain freely available here indefinitely", and the textbook is released under a Creative Commons Attribution 4.0 licence. A black-and-white paperback is sold separately for people who want paper.
What it covers
The book has an introduction and twelve chapters: Recursion, Backtracking, Dynamic Programming, Greedy Algorithms, Basic Graph Algorithms, Depth-First Search, Minimum Spanning Trees, Shortest Paths, All-Pairs Shortest Paths, Maximum Flows and Minimum Cuts, Applications of Flows and Cuts, and NP-Hardness. Every chapter ends with a long set of exercises, many of them taken from the author's own homework and exam problems. The same page also hosts extra lecture notes on more advanced topics, such as randomised algorithms and approximation algorithms, and separate notes on models of computation.
Why it stands out
Most algorithm resources show you a finished solution. This book spends its time on how you would have found it. The backtracking chapter builds every algorithm from the same question: what is the first decision, and what smaller problem is left after it? The dynamic programming chapter then turns those recursive backtracking algorithms into fast ones by noticing that the same smaller problems repeat. That order, recursion first and the table last, is exactly what makes DP stop feeling like magic.
The writing is precise but friendly, with jokes in the footnotes, and it is honest about which steps are hard. It assumes you can program and are comfortable with basic proofs by induction, which the introduction and recursion chapter warm you up for.
Who it suits
- Students taking a university algorithms course who want a second, clearer explanation of recursion, DP, greedy or graphs.
- Self-taught developers who can solve easy problems but get stuck on backtracking and dynamic programming.
- Anyone who wants to understand why a greedy choice is correct (the exchange argument) instead of guessing.
It is not a quick reference. If you only want a template for a pattern, a cheat sheet is faster. Come here when a pattern keeps failing you and you want to understand it properly.
How to use it well
- Read one chapter at a time next to problems on the same idea, not cover to cover.
- For backtracking and DP, write the recursive solution yourself in your language before reading the book's version, then compare.
- Try a few end-of-chapter exercises. They are harder than typical practice problems, and one solved slowly teaches more than ten solved by copying.
Free or paid?
The electronic book is free to read and download. A printed paperback is available to buy, but nothing in the book needs it.
Best for: learners who want to understand recursion, backtracking, dynamic programming, greedy and graph algorithms from first principles, for free.
Ready to start?
Opens on Jeff Erickson in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.