Algorithms learning guides
Learn the strategies that make programs faster, clearer, and more efficient.
Articles in Algorithms
- Big O Notation Without the Mystery — Describe how an algorithm scales as input grows, without getting distracted by machine-specific timing. 5 min read · 2026-10-28
- Binary Search: Halve the Search Space — A sorted collection can answer search questions quickly. Learn the invariant that keeps binary search correct. 5 min read · 2026-10-27
- Merge Sort: Divide, Sort, and Combine — Break a big sorting problem into smaller ones, then combine sorted halves in a predictable number of steps. 6 min read · 2026-10-26
- BFS vs. DFS: Two Ways to Explore a Graph — Use a queue to explore by distance or a stack to follow a path deep. Learn what each search guarantees. 6 min read · 2026-10-25
- Dynamic Programming: Remember Work You Already Did — Turn repeated subproblems into a table or cache, starting with a small recurrence you can reason about. 6 min read · 2026-10-24
- Dijkstra's Algorithm: Finding the Cheapest Route — Use a priority queue and repeated edge relaxation to find shortest paths in a graph with non-negative weights. 7 min read · 2026-10-28
- Recurrence Relations for Algorithm Analysis — A recurrence describes an algorithm's cost using the costs of smaller input sizes plus the work done at the current level. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Quicksort and Partitioning Around a Pivot — Quicksort partitions values around a pivot, then recursively sorts the smaller regions. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Insertion Sort and Nearly Sorted Data — Insertion sort builds a sorted prefix by shifting larger prefix values to make room for each next value. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Heap Sort: Selection with a Heap — Heap sort repeatedly removes the maximum from a heap and places it at the end of the array. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Counting Sort for Bounded Integer Ranges — Counting sort counts how often each key occurs and uses cumulative counts to place values without comparisons. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Radix Sort: Sorting Digits One Pass at a Time — Radix sort orders fixed-width keys by successive digits, using a stable inner sort for each digit. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Linear Search and Early Exit — Linear search checks values in sequence until it finds a target or reaches the end. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Tail Recursion and Explicit Stacks — Tail recursion makes the recursive call the final action, while an explicit stack stores pending work in an ordinary loop. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Backtracking: Explore and Undo Choices — Backtracking builds a candidate solution one choice at a time and undoes choices that cannot lead to a valid answer. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- N-Queens: Constraint Search on a Chessboard — The N-Queens problem places one queen per row while excluding shared columns and diagonals. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Greedy Algorithms and the Exchange Argument — A greedy algorithm commits to a locally attractive choice and needs a proof that this choice can belong to an optimal solution. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Interval Scheduling and Earliest-Finish Selection — Selecting compatible intervals by increasing finish time maximizes the number of non-overlapping intervals for the standard unweighted problem. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Memoization vs. Tabulation in Dynamic Programming — Memoization caches recursive subproblem results, while tabulation fills a table in a chosen dependency order. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- 0/1 Knapsack and State Design — The 0/1 knapsack dynamic program tracks the best value achievable for item prefixes and capacity limits. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Longest Increasing Subsequence: Two Useful Approaches — The longest increasing subsequence can be computed with a quadratic dynamic program or a patience-sorting-style tails array. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Edit Distance and Minimum String Repairs — Edit distance finds the minimum number of insertions, deletions, and substitutions needed to transform one string into another. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Topological Sorting and Dependency Order — A topological ordering places every directed acyclic graph vertex before the vertices that depend on it. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Minimum Spanning Trees: Connect at Minimum Cost — A minimum spanning tree connects every vertex of a connected weighted undirected graph with minimum total edge weight. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- A-Star Search and Admissible Heuristics — A-star ranks frontier states by path cost so far plus a heuristic estimate of remaining cost. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Bellman-Ford and Negative Edge Weights — Bellman-Ford relaxes every edge repeatedly and can detect reachable negative-weight cycles. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- KMP String Search and Prefix Information — Knuth-Morris-Pratt search reuses matched-prefix information so a mismatch does not restart comparison at the next text character. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Rolling Hashes for Fast Substring Candidates — A rolling hash updates a window hash as one character leaves and another arrives, making substring candidates cheap to compare. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Two Pointers for Ordered Pair Problems — Two pointers move through an ordered sequence from opposite ends or in the same direction to avoid checking every pair. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Sliding Windows for Contiguous Subarrays — A sliding window maintains state for a moving contiguous range, adding new values and removing values that leave. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29
- Prefix Sums for Constant-Time Range Totals — A prefix-sum array stores cumulative totals so a range sum is the difference of two prefix values. This guide works through a concrete example and the trade-offs to remember. 2 min read · 2026-10-29