Procedures that operate on data, as opposed to the ways of storing it in 02-data-structures.
The filing rule, and its one exception. If a note is about storing, it is a structure; if it is about doing, it is an algorithm. The exception is that an algorithm which belongs to exactly one structure is filed with that structure, because keeping it next to the vocabulary it assumes is what makes it readable. Two families have moved out of this folder on that basis:
- Tree traversal — pre-, in-, post- and level-order — lives in 02-data-structures/06-trees/04-traversal/.
- Graph traversal (DFS, BFS, edge classification) lives in 09-graphs/05-traversal/, and graph algorithms (topological sort, Dijkstra, MST, and the shortest-path family) live in 09-graphs/06-algorithms/.
What remains here is everything that is not the property of a single structure: the measuring system, the general problem-solving techniques, and the number and bit work.
Reading order
The foundation — read this before any data structure
- Complexity Analysis — [Beginner → Intermediate] — a folder. , and and why they are not interchangeable; best, average and worst case; space complexity; and amortised analysis with all three methods — aggregate, accounting and potential.
Everything in this course is quoted in the vocabulary that folder establishes, so it genuinely comes first — right after loops and what they cost.
Recursion
- Recursion — [Beginner → Advanced] — a folder: the three questions that produce a recursive function; the call stack and why space is the depth; recursion trees and recurrence relations; and the Master Theorem, including the two famous recurrences it cannot solve.
Searching, splitting and sorting
- Searching — [Beginner → Intermediate] — a folder: linear and binary search over a collection, binary search on the answer, and state-space search — the frontier, the explored set, heuristics and tie-breaking.
- Divide and Conquer — [Intermediate] — split, solve, combine, and why the combine step is the whole algorithm; choosing , and deliberately; why reducing the number of subproblems changes the exponent (Karatsuba, Strassen) while a cheaper combine changes at most a log factor; and a case where the technique applies and is still the wrong tool.
- Sorting — [Beginner → Advanced] — a folder: the lower bound and what it actually forbids, the elementary sorts, merge, quick, and the non-comparison sorts (counting, radix, bucket) that beat the bound by not comparing.
Techniques
- Greedy Algorithms — [Intermediate → Advanced] — a folder: when the locally best choice is provably right and the exchange argument that proves it; the coin-change trap; and the selection and scheduling family — hire-K-workers, where a group’s cost is a product rather than a sum, and interval scheduling, where only one of three plausible sort keys is correct.
- Dynamic Programming — [Intermediate → Advanced] — a folder: the two properties that make DP apply (both measured, not asserted); state, transition and base case; memoisation versus tabulation and why the transition dictates the fill order; space optimisation; and the classic one- and two-dimensional problems with reconstruction.
Number and bit work, and classic problems
- Number Theory Basics — [Intermediate] — primes, sieves, GCD, modular arithmetic.
- Leader / Majority — [Intermediate] — Boyer–Moore voting in space.
- Max Slice — [Intermediate] — Kadane’s algorithm and the maximum-subarray family.
- Bit Manipulation — [Intermediate] — masks, shifts, and the tricks worth recognising.
- Math and Geometry — [Intermediate] — matrix rotation, spiral traversal, coordinate reasoning.
What lives elsewhere, and where
| If you are looking for | Go to |
|---|---|
| Pre-, in-, post-order, level-order on a tree | 06-trees/04-traversal/ |
| DFS, BFS, edge classification | 09-graphs/05-traversal/ |
| Topological sort, Dijkstra, MST, shortest paths, A* | 09-graphs/06-algorithms/ |
| Backtracking, sliding window, two pointers, and the other recognition patterns | 04-patterns/ |
How these pair with the structures
| Algorithm | Wants |
|---|---|
| Counting / radix sort | arrays as buckets |
| Merge sort | a scratch array of size |
| Quicksort | the call stack, deep if you recurse on the smaller side |
| Binary search | a sorted random-access container |
| Dynamic programming | a table, or a memo dictionary |
| Sieve of Eratosthenes | a boolean array of size |
What is verified
Every finished note in this folder follows the course standard, alongside 02-data-structures and 04-patterns: stated prerequisites, observable outcomes, a runnable lab whose expected output was generated from an actual run, practice with a done when, and a demonstrable finish line.
Several labs exist to break the algorithm rather than to show it working:
| Lesson | What the lab demonstrates |
|---|---|
| complexity | the ratio per doubling is the complexity — 2.00x for , 4.01x for — and growing an array by one instead of doubling makes append |
| amortised analysis | a charge of 2 per append going into debt at while a charge of 3 never does; and the potential function holding the amortised cost at a flat 3 while actual costs run 1, 2, 3, 1, 5 |
| recursion | getrecursionlimit() reporting 1,000 while only 996 frames are usable; and naive Fibonacci making 242,785 calls for 26 distinct subproblems |
| Master Theorem | the gap case measuring doubling ratios of 2.55/2.49/2.44 — distinguishable from the wrong Case-3 answer by the numbers alone |
| divide and conquer | the max-subarray solution losing to Kadane’s linear scan by ~20x at — applicable is not optimal |
| binary search on the answer | the floor/ceil midpoint bug hanging at hi == lo + 1, and 300 random instances cross-checked against linear scan |
| state-space search | tree search costing 60x graph search by solution depth 10, because the state space is finite while the search tree is not |
| greedy selection | hire-K greedy agreeing with brute force 400/400 while “take the K cheapest wages” is wrong on 130/400; two plausible interval sort keys each failing on one input and tying on another |
| dynamic programming | a reversed fill order returning 0 instead of 34 with no error; the rolling knapsack’s upward loop returning 15 where the answer is 5; and merge sort’s subproblem redundancy measured at exactly 1.0x |
| searching | all three classic binary-search bugs failing: an infinite loop, a missed single element, and the JDK’s nine-year overflow |
| leader | the voting phase confidently returning a candidate that is not a majority |
| max slice | max(0, ...) Kadane’s answering a different question on all-negative input |
| greedy | greedy coin change failing on and , and 0/1 knapsack failing on the rule that is optimal for the fractional version |
| geometry | float slopes calling three points collinear when exact integer cross products say otherwise |
Where a lab claims an output, that output came from executing the code.
Question banks
One bank per lesson: micro-questions with the answers hidden behind toggles, for closed-book recall rather than reading. Method explained in the arrays bank.
- Divide and Conquer
- Number Theory Basics
- The Leader Algorithm
- Max Slice Algorithms
- Bit Manipulation
- Math & Geometry
- Complexity Analysis — banks for that folder’s lessons
- Recursion — banks for that folder’s lessons
- Sorting — banks for that folder’s lessons
- Searching — banks for that folder’s lessons
- Dynamic Programming — banks for that folder’s lessons
- Greedy Algorithms — banks for that folder’s lessons
Related
- dsa/ — the parent course and full reading order
- 02-data-structures — what these operate on
- 04-patterns — the problem-recognition layer above both
- Course standard — the shape the converted folders follow
Software engineering
Infrastructure & security
Computer science
Hardware & engineering