Major named algorithms, grouped by problem domain, each solving one well-defined problem. For the full alphabetical list of every named algorithm/theorem/structure mentioned anywhere in the notes (much longer, no grouping), see đŹ Named Algorithms . For the general strategies these are instances of, see đŹ Paradigms ; for cross-cutting tricks, đŹ Techniques ; for the structures they run on, đŹ Data Structures .
Sorting
Algorithm Solves Complexity Note Merge sort stable comparison sort O ( n log n ) Sorting Quicksort in-place comparison sort O ( n log n ) expectedSorting Counting / radix sort sort by small-range or fixed-width keys O ( n + k ) / O ( n d ) Sorting
Searching
Algorithm Solves Complexity Note Binary search (and variants) find a boundary in a monotone predicate O ( log n ) Binary Search Ternary / golden-section search optimum of a unimodal function O ( log n ) Ternary Search
Graph shortest paths
Algorithm Solves Complexity Note Dijkstraâs algorithm single-source shortest paths, non-negative weights O ( m log n ) Shortest Paths BellmanâFord single-source shortest paths, negative weights, cycle detection O ( nm ) Shortest Paths FloydâWarshall all-pairs shortest paths O ( n 3 ) Shortest Paths SPFA BellmanâFord with a queue, usually faster, adversarially slow O ( nm ) worst caseShortest Paths Johnsonâs algorithm all-pairs shortest paths, negative weights allowed O ( nm log n ) Shortest Paths 0-1 BFS shortest paths, weights in { 0 , 1 } O ( n + m ) Shortest Paths Suurballeâs algorithm two vertex-disjoint shortest paths O ( m log n ) Shortest Path Techniques Eppsteinâs algorithm k shortest pathsO ( m log m + k log k ) K Shortest Paths
Graph structure
Minimum spanning trees
Flows and matching
Algorithm Solves Complexity Note FordâFulkerson / EdmondsâKarp maximum flow O ( n m 2 ) (EdmondsâKarp)Max Flow Dinicâs algorithm maximum flow O ( n 2 m ) , O ( m m â ) unit-capMax Flow Pushârelabel maximum flow O ( n 2 m â ) Push-Relabel HopcroftâKarp maximum bipartite matching O ( m n â ) Bipartite Matching Hungarian algorithm (KuhnâMunkres) minimum-cost perfect bipartite matching O ( n 3 ) Assignment Problem Blossom algorithm maximum matching in a general graph O ( n 3 ) General Matching GaleâShapley a stable matching O ( n 2 ) Stable Matching StoerâWagner global minimum cut O ( n 3 ) Global Min Cut
Strings
Algorithm Solves Complexity Note KnuthâMorrisâPratt (KMP) single-pattern matching via the prefix function O ( n + m ) Prefix Function and Z Z-algorithm single-pattern matching via the Z-function O ( n + m ) Prefix Function and Z Manacherâs algorithm longest palindromic substring at every center O ( n ) Palindromes AhoâCorasick multi-pattern matching $O(\sum p_i Boothâs algorithm lexicographically minimal rotation O ( n ) String Basics SA-IS suffix array construction O ( n ) Suffix Array Ukkonenâs algorithm online suffix tree construction O ( n ) Suffix Tree
Number theory
Algorithm Solves Complexity Note Fast Fourier Transform (FFT) polynomial multiplication over C O ( n log n ) FFT Number Theoretic Transform (NTT) polynomial multiplication mod an NTT-friendly prime O ( n log n ) NTT Fast WalshâHadamard Transform (FWHT) XOR/AND/OR convolution O ( n log n ) Convolution Variants
Computational geometry
Algorithm Solves Complexity Note Andrewâs monotone chain convex hull O ( n log n ) Convex Hull Rotating calipers diameter/width of a convex polygon, closest pair of parallel lines, etc. O ( n ) after a hullRotating Calipers BentleyâOttmann all segment intersections O (( n + k ) log n ) Sweep Line Welzlâs algorithm minimum enclosing circle O ( n ) expectedMinimum Enclosing Circle
Combinatorics
Algorithm Solves Complexity Note Burnsideâs lemma / PĂłlya enumeration counting objects up to symmetry problem-dependent Burnside and PĂłlya