Algorithms
An algorithm is a concrete method with an argument for its correctness and a bound on its cost — the difference between a program that works on your laptop and one that holds up at scale.
Correctness comes first. Before you ask whether an algorithm is fast, you ask whether it is right — an invariant that holds at every step, a base case that grounds the recursion, an argument that the loop must end.
The core skill is then reasoning about cost before you write a line of code. Asymptotic analysis lets you compare strategies on paper and predict which scales to a million inputs and which becomes impractical at a thousand.
Big-O strips away the constants and the hardware to leave the one thing that matters at scale: how the work grows as the input does. A linear pass and a quadratic one are indistinguishable on ten items and orders of magnitude apart on ten million.
Most hard problems yield to a handful of ideas — divide & conquer, greedy choices, dynamic programming, and well-chosen data structures. Learn the ideas once and you start to recognize them everywhere.
Data structures are the other half. The right one — a heap, a hash table, a balanced tree, a union-find — turns an expensive operation into a cheap one.
And when a problem is genuinely intractable, you learn to prove it — so you stop searching for an efficient algorithm that cannot exist, and start designing approximations that can.
The subject teaches you to find a good solution, justify it, and know when no better one is possible.
Contents.
1. Foundations
3. Sorting & Order Statistics
4. Data Structures
5. Sequences & Strings
6. Graphs
- Graph Representations and Traversal
- Depth-First Search
- Topological Sort and Strong Connectivity
- Minimum Spanning Trees
- Kruskal and Prim
- Shortest Paths
- All-Pairs and Negative Weights
- Network Flow
- Max-Flow Min-Cut and Applications
- Bridges & Articulation Points
- Lowest Common Ancestor & Binary Lifting
- 2-SAT via Implication Graphs
- Eulerian Tours
- Bipartite Matching