The Little Book of Algorithms

Version 0.2.0

Author

Duc-Tam Nguyen

Published

September 17, 2025

Contents

Volume 1 — What Is an Algorithm?

  1. Problems, procedures, and precision
  2. Inputs, outputs, and assumptions
  3. Deterministic vs. nondeterministic steps
  4. Decomposing big problems into small ones
  5. Abstraction: hiding details to see structure
  6. Representing data: numbers, text, and simple records
  7. Correctness as a promise: pre/postconditions
  8. Cost as effort: time, memory, and simplicity
  9. Algorithms vs. heuristics: when “good enough” wins
  10. A tiny toolbox: three everyday recipes (sum, max, count)

Volume 2 — Describing Algorithms Clearly

  1. Pseudocode that reads like plain English
  2. Flowcharts and step diagrams
  3. Tracing by hand: dry runs on small examples
  4. Input modeling: choose the right shape for data
  5. Edge cases: empties, extremes, and errors
  6. Step-invariants: what stays true while we work
  7. Assertions and sanity checks
  8. Naming things and writing clear steps
  9. Turning pictures into procedures
  10. From idea to draft algorithm

Volume 3 — Reasoning About Cost (Complexity Without Tears)

  1. Constant time vs. growing time
  2. Counting simple loops
  3. Nested loops as grids of work
  4. Best, average, worst case thinking
  5. Space cost and data copies
  6. Big-O intuition (skip the calculus)
  7. Practical performance vs. asymptotics
  8. Lower bounds as “can’t do better than”
  9. Trade-offs: time vs. space vs. simplicity
  10. Measuring in practice: micro-bench basics

Volume 4 — Data Building Blocks I: Arrays, Lists, Queues, Stacks

  1. Arrays: indexed shelves
  2. Traversal patterns and two-pointers
  3. Dynamic arrays: growth and amortized cost
  4. Linked lists: chains of nodes
  5. Insert, delete, and search patterns
  6. Stacks: undo, parse, and backtrack
  7. Queues: first-in first-out thinking
  8. Deques and circular buffers
  9. Choosing between list and array
  10. Real-world mini-projects (logs, history, task queues)

Volume 5 — Data Building Blocks II: Trees, Hashes, and Graphs (Gentle)

  1. Trees as nested boxes
  2. Binary trees and traversal orders
  3. Balanced vs. unbalanced intuition
  4. Hash tables: buckets from good mixing
  5. Handling collisions: chaining and open addressing
  6. Sets and maps as interfaces
  7. Graphs as connections: nodes and edges
  8. Adjacency lists vs. matrices
  9. Weighted, directed, and bipartite basics
  10. Modeling real problems with graphs

Volume 6 — Searching and Sorting Fundamentals

  1. Linear search and sentinel tricks
  2. Binary search: halving the haystack
  3. Sorting goals and stability
  4. Selection: find min/max, kth element
  5. Insertion sort: simple and local
  6. Merge sort: split, sort, merge
  7. Quick sort: partition and pivot
  8. Counting and bucket sort: when keys are small
  9. Practical mixtures and fallbacks
  10. Where sorting shows up in life

Volume 7 — Recursion & Divide-and-Conquer

  1. The recursive mindset: self-reference safely
  2. Base cases and progress measures
  3. Visualizing call stacks
  4. Classic examples (factorial, Fibonacci, binary search)
  5. Divide-and-conquer pattern
  6. Recurrence intuition (without heavy math)
  7. Tail recursion and iteration conversion
  8. Handling duplicates and boundaries cleanly
  9. Debugging recursive code
  10. Recursion in real tasks (parsing, image quadrants)

Volume 8 — Greedy Algorithms

  1. What “locally best” means
  2. Exchange arguments (why greedy can be right)
  3. Interval scheduling and activity selection
  4. Making change (when greedy works, when it fails)
  5. Huffman coding intuition
  6. Spanning trees with a greedy flavor
  7. Greedy on graphs: pitfalls and patterns
  8. Greedy vs. dynamic programming: choose wisely
  9. Counterexamples as teaching tools
  10. Greedy checklists before you code

Volume 9 — Dynamic Programming (DP) for Humans

  1. Overlapping subproblems and optimal substructure
  2. From recursion to memoization
  3. Bottom-up tables and state diagrams
  4. Longest common subsequence (LCS) story
  5. Knapsack as choices on a grid
  6. Path counting on grids with obstacles
  7. Edit distance and spell-check vibes
  8. Reconstructing solutions from tables
  9. Space-saving DP tricks
  10. Recognizing DP opportunities in the wild

Volume 10 — Graph Algorithms I: Exploration

  1. BFS: layers and shortest hops
  2. DFS: depth trails and classification of edges
  3. Connectivity: components and islands
  4. Detecting cycles (directed/undirected)
  5. Topological sort on DAGs
  6. Using parents, levels, and timestamps
  7. Flood fill and maze solving
  8. Graph modeling patterns (grids, states)
  9. Traversal pitfalls: visited sets and resets
  10. When not to use graphs

Volume 11 — Graph Algorithms II: Paths and Trees

  1. Weighted shortest paths mindset
  2. Dijkstra: non-negative weights
  3. Bellman–Ford: handle negatives carefully
  4. All-pairs sketch: repeated single-source
  5. Minimum spanning trees: cut and cycle views
  6. Kruskal vs. Prim: data structure choices
  7. Union-Find (Disjoint Set Union) basics
  8. DAG shortest paths as DP
  9. Graph heuristics in practice (A* intuition)
  10. Modeling road networks and deliveries

Volume 12 — Strings, Text, and Patterns

  1. Strings as arrays of characters
  2. Naive pattern matching and sliding windows
  3. Prefix-function intuition (KMP idea, gently)
  4. Z-function and borders (conceptual)
  5. Rolling hash and Rabin–Karp
  6. Tries for dictionaries and autocomplete
  7. Simple compression ideas (run-length, Huffman revisit)
  8. Tokenization and normalization basics
  9. Anagrams, palindromes, frequency maps
  10. Real tasks: search, dedup, and logs

Volume 13 — Geometry and Spatial Algorithms

  1. Points, vectors, and distances (no heavy math)
  2. Orientation tests: left, right, collinear
  3. Bounding boxes and collision checks
  4. Line segments: intersect or not
  5. Polygons: perimeter, area, and winding
  6. Grid geometry: raster thinking
  7. Closest pair (divide-and-conquer idea)
  8. Convex hull intuition
  9. Spatial indexing intuition (quadtrees)
  10. Practical tasks: maps, games, and UI hit-testing

Volume 14 — Probability & Randomized Algorithms (Gentle)

  1. Randomness as a tool, not magic
  2. Sampling fairly and shuffling
  3. Reservoir sampling for streams
  4. Monte Carlo vs. Las Vegas algorithms
  5. Randomized quickselect intuition
  6. Hashing and probabilistic data structures (bloom filter intuition)
  7. Expectations without heavy formulas
  8. Estimating large counts (Flajolet–Martin idea)
  9. Random walks and simple simulations
  10. When to prefer randomized approaches

Volume 16 — Numbers, Data, and Simple Numerics

  1. Integer limits, overflow, and safe arithmetic
  2. Fixed vs. floating-point intuition
  3. Summation stability and Kahan idea (gently)
  4. Binary, decimal, and bases
  5. Greatest common divisor and Euclid
  6. Prime checks (simple) and factoring (why it’s hard)
  7. Modular arithmetic intuition
  8. Root finding with bisection (no calculus)
  9. Interpolation and simple smoothing
  10. Units, precision, and error budgets

Volume 17 — Working with Big Data (Beginner-Level Ideas)

  1. Memory vs. disk: locality matters
  2. Chunking and batching
  3. External sorting idea
  4. Streaming: one pass, small memory
  5. Map-Reduce as a mental model
  6. Sketches for big counts (count-min intuition)
  7. Windowed aggregates on streams
  8. Caching and eviction (LRU intuition)
  9. Parallelism vs. concurrency (plain language)
  10. Practical hygiene: logs, checkpoints, retries

Volume 18 — Practical Algorithms in Everyday Software

  1. Rate limiting (token/leaky bucket intuition)
  2. Consistent hashing (balanced placement idea)
  3. Pagination, search, and ranking basics
  4. Recommendation heuristics (co-occurrence intuition)
  5. Deduplication and fuzzy matching
  6. Scheduling jobs and throttling
  7. Pathfinding in apps and games
  8. Simple image operations (filters as kernels)
  9. Text pipelines (tokenize → normalize → index)
  10. “Good enough” engineering: latency and budgets

Volume 19 — Designing Algorithms: A Playbook

  1. Clarify the goal and constraints
  2. Model the data and operations
  3. Choose patterns: brute force → prune → optimize
  4. Identify invariants and loop structure
  5. Prove or test correctness (lightweight)
  6. Estimate cost and pick the right order of growth
  7. Simplify first; optimize last
  8. Reuse libraries vs. reinventing
  9. Communicate the approach (diagrams & docs)
  10. Post-mortems: learn from misses

Volume 20 — Capstones, Case Studies, and Practice

  1. Route planner for a small city (graphs)
  2. Personal finance analyzer (arrays, scans, DP lite)
  3. Study planner/scheduler (greedy + constraints)
  4. Document search and dedup (strings + hashing)
  5. Inventory allocator (greedy vs. DP trade-offs)
  6. Game pathfinding and AI (BFS/A*)
  7. Image cleanup mini-tool (filters + queues)
  8. Log analyzer for trends (streaming + sketches)
  9. Data cleaning pipeline (practical robustness)
  10. Build your own algorithm notebook (templates, checklists)