Algorithms & DP

Algorithms & DP

Algorithms & Dynamic Programming — animated visualizations, DP tables, recursion trees, complexity walkthroughs.

388Articles
388Topics covered
Articles in this category

All 388 articles, sorted alphabetically

Advertisement
ARTICLE · 01

2-Edge-Connected Components + Bridge Tree

Group vertices connected without using bridges. Tree structure of bridges.

Read article
ARTICLE · 02

A* Algorithm

Add h(n) estimate to guide search. Optimal + admissible = optimal path.

Read article
ARTICLE · 03

A* Pathfinding

Optimal shortest path with heuristic guidance. Basis of game AI + robotics.

Read article
ARTICLE · 04

A* Variants

Memory-bounded, anytime, and dynamic replanning A* variants.

Read article
ARTICLE · 05

Activity Selection

Sort by end time + take non-conflicting activities. Provable optimality.

Read article
ARTICLE · 06

AES-GCM

Counter-mode AES + GHASH universal hash. Parallel + hardware accelerated.

Read article
ARTICLE · 07

AES

Rijndael, 128/192/256-bit keys, 10/12/14 rounds. Backbone of modern symmetric crypto.

Read article
ARTICLE · 08

Aho-Corasick

Trie + failure links = search for many patterns in text in linear time.

Read article
ARTICLE · 09

All-Pairs Shortest Paths

Floyd-Warshall O(V³). Johnson O(V²log V + VE). Sub-cubic via Seidel, Zwick.

Read article
ARTICLE · 10

Signed Area of Polygon

Sum of cross products. Sign indicates orientation.

Read article
ARTICLE · 11

Art Gallery Theorem

Simple polygon with N vertices needs at most ⌊N/3⌋ guards to see all interior.

Read article
ARTICLE · 12

Attention Mechanism

Weight input positions by learned relevance. Backbone of GPT + BERT + all modern LLMs.

Read article
ARTICLE · 13

AVL Tree

Height-balanced BST with left/right rotations to maintain balance factor.

Read article
ARTICLE · 14

B+ Tree

All data in leaves, leaves linked. Sequential scans are trivial.

Read article
ARTICLE · 15

B-Tree

M-ary tree with keys per node = disk page size. Foundation of most database indexes.

Read article
ARTICLE · 16

Balanced Binary Tree Check

Is the tree height-balanced? O(N) with early termination.

Read article
ARTICLE · 17

Bayesian Optimization

Gaussian Process posterior + acquisition function. Sample-efficient black-box optimization.

Read article
ARTICLE · 18

Bellman-Ford

V-1 rounds of edge relaxation. Detects negative cycles.

Read article
ARTICLE · 19

Bellman-Ford

Slower than Dijkstra but handles negative edges and detects negative cycles.

Read article
ARTICLE · 20

BERT

Masked language model + next-sentence prediction. Sparked LLM era.

Read article
ARTICLE · 21

Betweenness Centrality

Fraction of shortest paths through vertex. Brandes: O(VE) instead of O(V³).

Read article
ARTICLE · 22

Breadth-First Search

BFS visits nodes in level order. Watch it happen with a queued animation.

Read article
ARTICLE · 23

BFS on Grids

Grid-specific BFS: 4/8-connectivity, boundary tricks, virtual super-node.

Read article
ARTICLE · 24

BFS on Implicit Graphs

Graph too large to materialize. Generate neighbors on the fly.

Read article
ARTICLE · 25

BFS with Augmented State

Node = (position, extra info). Grid + keys, TSP-like, portal problems.

Read article
ARTICLE · 26

0-1 BFS

Deque replaces PQ. Edges of weight 0 push to front, weight 1 to back.

Read article
ARTICLE · 27

Biconnected Components

Maximal subgraphs where removing any single vertex leaves connected. DFS + low-link.

Read article
ARTICLE · 28

Bidirectional BFS

Search from both source and target. Meet halfway → 2x speedup at least.

Read article
ARTICLE · 29

Binary Tree In-Order Traversal

Left → Root → Right visits nodes in sorted order (for BSTs). Watch the animation.

Read article
ARTICLE · 30

Binary Tree Level-Order Traversal (BFS)

Visit nodes level by level with a queue. Powers view problems + zigzag.

Read article
ARTICLE · 31

Binary Tree Post-Order Traversal

Left → Right → Root. Perfect for tree deletion + expression evaluation.

Read article
ARTICLE · 32

Binary Tree Pre-Order Traversal

Root → Left → Right. Perfect for serialization + tree copying.

Read article
ARTICLE · 33

Bipartite Check

Bipartite iff no odd cycle. BFS 2-color test in O(V+E).

Read article
ARTICLE · 34

Bipartite Matching

Match items across two sets. Bipartite specialization + weighted assignment.

Read article
ARTICLE · 35

Bitap Algorithm

Bit tricks for pattern matching with errors. Fast for short patterns.

Read article
ARTICLE · 36

Bloom Filter

K hash functions + bit array. Definitely-not-in vs probably-in. Massive space savings.

Read article
ARTICLE · 37

Blossom Algorithm

Edmonds' blossom shrinking. Non-bipartite maximum matching in O(V·E·α(V)).

Read article
ARTICLE · 38

Borůvka's Algorithm

Each component picks its cheapest outgoing edge in parallel. Halves components per round.

Read article
ARTICLE · 39

Boundary Traversal of Binary Tree

Left boundary → leaves → right boundary (reversed).

Read article
ARTICLE · 40

Bounded Knapsack

Each item has a limit. Handled via binary decomposition to reduce to 0/1.

Read article
ARTICLE · 41

Boyer-Moore

Fast pattern match in practice. Sublinear expected on random text.

Read article
ARTICLE · 42

Bridge Detection

Detect bridges as edges added. Fully online via link-cut trees.

Read article
ARTICLE · 43

Bridges + Articulation Points (Tarjan's)

Find critical edges/nodes whose removal disconnects graph. Single DFS.

Read article
ARTICLE · 44

BST Insert + Search + Delete Operations

Binary search tree fundamentals with animated insertion.

Read article
ARTICLE · 45

BST Validation

Recursively check each node against inherited bounds.

Read article
ARTICLE · 46

Build Binary Tree From Two Traversals

Preorder + Inorder OR Postorder + Inorder uniquely determines a tree.

Read article
ARTICLE · 47

Burrows-Wheeler Transform

BWT rearranges string to be more compressible. Basis of bzip2 + FM-index.

Read article
ARTICLE · 48

Cactus Graphs

Structured graph class where many NP-hard problems become polynomial.

Read article
ARTICLE · 49

Cartesian Tree

Build tree where in-order = array + heap property on values. Enables O(1) RMQ.

Read article
ARTICLE · 50

Catalan Numbers

C_n = C(2n, n) / (n+1). Counts binary trees, balanced parens, etc.

Read article
ARTICLE · 51

Katz Centrality

Sum over paths of length k, weighted by α^k. Generalizes eigenvector centrality.

Read article
ARTICLE · 52

Centroid Decomposition

Recursively split tree at centroid. Each level halves subtree size. O(log N) levels.

Read article
ARTICLE · 53

ChaCha20-Poly1305

Stream cipher + universal-hash MAC. Fast in software, no side-channels.

Read article
ARTICLE · 54

Chinese Postman Problem

Find shortest tour visiting every edge. Reduces to Eulerian + matching.

Read article
ARTICLE · 55

Batched CRT

Compute mod several small primes → combine via CRT. Avoids big-integer cost.

Read article
ARTICLE · 56

Chinese Remainder Theorem

System x ≡ aᵢ (mod nᵢ) has unique solution mod ∏nᵢ if all nᵢ coprime.

Read article
ARTICLE · 57

Personalized PageRank

PageRank biased toward preferred nodes. Foundation of recommendations.

Read article
ARTICLE · 58

SCC Condensation

Contract each SCC to node → DAG. Enables DP on SCCs.

Read article
ARTICLE · 59

Chordal Graphs

Perfect elimination ordering enables polynomial algorithms for many problems.

Read article
ARTICLE · 60

Chromatic Polynomial

P(G, k) = number of proper k-colorings. Deletion-contraction recurrence.

Read article
ARTICLE · 61

Chu-Liu-Edmonds

MST for directed graphs. Contracts min-in-edge cycles iteratively.

Read article
ARTICLE · 62

Circular Linked List

Last node points back to head. Uses in scheduling + streaming.

Read article
ARTICLE · 63

Circulation Problem

Each edge has lower + upper capacity bounds. Reduce to max-flow.

Read article
ARTICLE · 64

Closest Pair of Points

Sort by x, recurse, merge with strip check.

Read article
ARTICLE · 65

Convolutional Neural Networks

Weight sharing + local receptive fields. Image processing before ViT.

Read article
ARTICLE · 66

Coin Change

Count ways to make amount N using unlimited coins. DP.

Read article
ARTICLE · 67

CGAL + GEOS + Boost.Geometry

Robust geometry code is hard. Use libraries.

Read article
ARTICLE · 68

Connected Components

Iterate unvisited vertices, DFS from each. Component count.

Read article
ARTICLE · 69

Constrained Shortest Path

Minimize cost subject to resource budget. NP-hard, DP or Lagrangian.

Read article
ARTICLE · 70

Continued Fractions

Represent real as a₀ + 1/(a₁ + 1/(a₂ + …)). Convergents give best approximations.

Read article
ARTICLE · 71

Contraction Hierarchies

Precompute node ordering + shortcuts. Query in ms on billion-node graphs.

Read article
ARTICLE · 72

Andrew's Monotone Chain

Sort by x, build lower + upper hulls with cross-product tests.

Read article
ARTICLE · 73

Convex Hull

Smallest convex polygon containing all points. Sort by angle + linear stack scan.

Read article
ARTICLE · 74

QuickHull

Analog of quicksort. Expected O(N log N), worst O(N²).

Read article
ARTICLE · 75

Convex Layers

Compute hull, remove, repeat. All layers in O(N log N).

Read article
ARTICLE · 76

Convex Polygon Intersection

Two convex polygons: intersect in linear time via O'Rourke's chase algorithm.

Read article
ARTICLE · 77

Deep Copy List with Random Pointer

Copy list where each node has next + arbitrary random pointer.

Read article
ARTICLE · 78

Cycle Detection in Directed Graph

DFS with 3-color coloring: back edge = cycle. Or topological sort success.

Read article
ARTICLE · 79

Cycle Detection

Two-pointer meeting in cycle. O(N) time, O(1) space.

Read article
ARTICLE · 80

Cycle Detection in Undirected Graph

DFS: any edge to non-parent visited vertex = cycle. Union-Find alternative.

Read article
ARTICLE · 81

DBSCAN

Cluster = dense regions. Handles arbitrary shapes + noise. No k needed.

Read article
ARTICLE · 82

Decision Trees

Recursive binary splits minimizing impurity. Foundation of RF + GBDT.

Read article
ARTICLE · 83

DeepWalk

Predecessor to node2vec. Uniform walks + skip-gram. Foundation of graph embedding era.

Read article
ARTICLE · 84

Delaunay Triangulation

Triangulate points such that no point lies inside any triangle's circumcircle.

Read article
ARTICLE · 85

Depth-First Search

DFS goes deep before wide. Foundation of topological sort, cycle detection, and more.

Read article
ARTICLE · 86

DFS Tree

During DFS, edges classify as tree, back, forward, cross. Foundation of many algorithms.

Read article
ARTICLE · 87

Dial's Algorithm

Bucket queue instead of PQ. O(E + V×C) for max weight C.

Read article
ARTICLE · 88

Diffie-Hellman

Alice + Bob agree on shared secret via public messages. No prior sharing needed.

Read article
ARTICLE · 89

Digital Signatures

Non-repudiation + integrity + authenticity. Foundation of PKI + software distribution.

Read article
ARTICLE · 90

Bidirectional Dijkstra

Run Dijkstra from source AND target. Meet in middle. 2x+ speedup.

Read article
ARTICLE · 91

Dijkstra's Algorithm

Single-source shortest paths with non-negative weights. Priority queue + relaxation.

Read article
ARTICLE · 92

Dijkstra with Fibonacci Heap

Amortized O(1) decrease-key gives Dijkstra its theoretical best.

Read article
ARTICLE · 93

Dijkstra's Shortest Path

Priority queue + edge relaxation give shortest paths from source in weighted graphs.

Read article
ARTICLE · 94

Dijkstra with Potentials

Add potential function → shifted edge weights → efficient repeated queries.

Read article
ARTICLE · 95

Dinic's Algorithm

BFS to build level graph, DFS for blocking flow. O(V²·E). O(E·√V) on bipartite.

Read article
ARTICLE · 96

Dominator Tree

u dominates v iff every path from root passes u. Tree structure. Compilers use it.

Read article
ARTICLE · 97

Doubly Linked List

Prev + next pointers enable O(1) removal given node reference.

Read article
ARTICLE · 98

0/1 Knapsack Problem

The classic knapsack: fill a 2D DP table row by row.

Read article
ARTICLE · 99

Burst Balloons

Choose burst order to maximize coins. Reverse-thinking interval DP.

Read article
ARTICLE · 100

Coin Change

Min coins to make amount + count ways to make amount. Same problem, different DP.

Read article
ARTICLE · 101

Edit Distance (Levenshtein)

Insert, delete, replace: three transitions in a 2D DP.

Read article
ARTICLE · 102

Egg Drop Problem

Find minimum trials to identify critical floor with limited eggs.

Read article
ARTICLE · 103

Fibonacci

The canonical DP intro problem: recursion tree, memoization, tabulation, and space optimization.

Read article
ARTICLE · 104

House Robber Problem

Non-adjacent selection problem with elegant O(1) space.

Read article
ARTICLE · 105

Dynamic Programming

The four-step DP framework, visualized with a live-filling table.

Read article
ARTICLE · 106

Longest Common Subsequence (LCS)

Find the longest sequence appearing in both strings, in order.

Read article
ARTICLE · 107

Longest Increasing Subsequence (LIS)

O(N²) DP + O(N log N) patience sort.

Read article
ARTICLE · 108

Matrix Chain Multiplication

Optimal parenthesization for matrix multiplication order.

Read article
ARTICLE · 109

Maximum Subarray Sum

Elegant O(N) DP for max contiguous sum.

Read article
ARTICLE · 110

Optimal Binary Search Tree

Build a BST with minimum expected search cost given key frequencies.

Read article
ARTICLE · 111

Paint House Problem

Paint N houses with 3 colors, no two adjacent same. Classic state DP.

Read article
ARTICLE · 112

Palindrome Partitioning

Partition string into palindromes with minimum cuts. Two DPs combined.

Read article
ARTICLE · 113

Partition Equal Subset Sum

Can we partition array into two equal-sum subsets? Subset-sum problem.

Read article
ARTICLE · 114

Regular Expression Matching

Match string against pattern with . and * — 2D DP handles it elegantly.

Read article
ARTICLE · 115

Best Time to Buy and Sell Stock

Buy + sell with cooldown, transaction fee, or k transactions — state machine DP handles all.

Read article
ARTICLE · 116

Unique Paths in Grid

Number of paths from top-left to bottom-right, only moving right or down.

Read article
ARTICLE · 117

Word Break Problem

Can a string be segmented into dictionary words? 1D DP with substring lookups.

Read article
ARTICLE · 118

ECDSA

Elliptic curve version of DSA. Bitcoin + TLS use it. Requires cryptographic randomness.

Read article
ARTICLE · 119

Ed25519

Fast, secure, small signatures. Bernstein's design. SSH + JWT + modern protocols.

Read article
ARTICLE · 120

Edit Distance

Min insert/delete/replace to transform s into t. O(N·M) DP.

Read article
ARTICLE · 121

Edmonds-Karp

Ford-Fulkerson with shortest augmenting path (BFS). O(V·E²).

Read article
ARTICLE · 122

Eigenvector Centrality

Score = eigenvector of adjacency matrix. High score = connected to other high scores.

Read article
ARTICLE · 123

Elliptic Curve Cryptography (ECC)

Groups on elliptic curves enable smaller keys with same security. Standard in modern crypto.

Read article
ARTICLE · 124

Epidemic Models on Networks

How disease spreads via graph structure. Basic reproduction number R₀.

Read article
ARTICLE · 125

Euclidean Algorithm

Ancient algorithm. gcd(a, b) = gcd(b, a mod b). Foundation of number theory.

Read article
ARTICLE · 126

Euclidean MST

MST on complete graph of points. O(N log N) via Delaunay triangulation.

Read article
ARTICLE · 127

Euler's Totient Function

Number of integers in [1, n] coprime to n. Core of RSA.

Read article
ARTICLE · 128

Euler Tour Technique

Flatten tree into array via DFS enter/exit times. Range queries → subtree queries.

Read article
ARTICLE · 129

Eulerian Path

Find path using each edge exactly once. Linear time.

Read article
ARTICLE · 130

Expander Graphs

Constant-degree graphs with rapid mixing. Fundamental in CS + math.

Read article
ARTICLE · 131

Expectation-Maximization

Iterative MLE with hidden variables. Foundation of GMM, HMM, LDA training.

Read article
ARTICLE · 132

Extended Euclidean Algorithm

Compute gcd + x, y such that a·x + b·y = gcd(a, b). Foundation of modular inverses.

Read article
ARTICLE · 133

Fast Fourier Transform (FFT)

Compute DFT in O(N log N). Foundation of signal processing + fast multiplication.

Read article
ARTICLE · 134

Fast Polynomial Multiplication

Multiply degree-N polynomials in O(N log N). Beats schoolbook O(N²).

Read article
ARTICLE · 135

Fenwick Tree (BIT)

Simpler than segment tree, same O(log N) prefix sums + point updates.

Read article
ARTICLE · 136

2D Fenwick Tree

BIT extended to 2D: O((log N)²) per op.

Read article
ARTICLE · 137

Fibonacci Computation

F_n in O(log n): matrix power or fast doubling.

Read article
ARTICLE · 138

Find Middle of Linked List

Single pass, two pointers. Slow ends at middle when fast hits end.

Read article
ARTICLE · 139

Finger Tree

2-3 tree variant with 'fingers' giving O(1) access to both ends.

Read article
ARTICLE · 140

Flood Fill

Fill connected region of same value. Paint bucket tool.

Read article
ARTICLE · 141

Floyd-Warshall

O(V³) DP over intermediate vertices. Works with negative weights (no negative cycles).

Read article
ARTICLE · 142

Fractional Cascading

Precompute pointers between sorted lists to eliminate repeated binary searches.

Read article
ARTICLE · 143

Fractional Knapsack

Sort by value/weight ratio, take highest ratio first. O(N log N).

Read article
ARTICLE · 144

Gabow's SCC Algorithm

Alternative to Tarjan's low-link. Uses two stacks, single DFS.

Read article
ARTICLE · 145

Game Tree Search

Two-player zero-sum games. Depth-limited search with pruning.

Read article
ARTICLE · 146

Gas Station Circular Route

Find starting station to complete circular route. Elegant O(N) greedy.

Read article
ARTICLE · 147

Girvan-Newman

Iteratively remove highest-betweenness edges. Reveals hierarchical community structure.

Read article
ARTICLE · 148

Gomory-Hu Tree

One tree encodes minimum s-t cut for every pair. N-1 max-flow calls.

Read article
ARTICLE · 149

GPT

Autoregressive next-token prediction. Foundation of ChatGPT/Claude/Gemini.

Read article
ARTICLE · 150

Gradient Boosting

Sequential boosting. Each tree fits residuals. Winner of most Kaggle tabular competitions.

Read article
ARTICLE · 151

Gradient Descent

First-order optimization. Foundation of neural network training.

Read article
ARTICLE · 152

Graph Attention Networks (GAT)

Attention over neighbors. Weights not uniform — learned per edge.

Read article
ARTICLE · 153

Graph Convolutional Networks (GCN)

Simplified GNN: normalized adjacency × features × weights.

Read article
ARTICLE · 154

Graph Diameter

Max over all (u,v) of dist(u,v). Various tricks + approximations.

Read article
ARTICLE · 155

Graph Isomorphism

Determine if two graphs are structurally identical. Neither P nor NP-hard (unknown).

Read article
ARTICLE · 156

Graph Kernels

Kernel functions comparing two graphs. Used in SVMs for graph classification.

Read article
ARTICLE · 157

Graph Neural Networks

Aggregate neighbor features. Layer-wise propagation. Standard GNN framework.

Read article
ARTICLE · 158

Greedy Graph Coloring

Order vertices by degree, color each with lowest available. Simple + fast.

Read article
ARTICLE · 159

Group Knapsack

Items partitioned into groups. Pick at most 1 from each. Common in course scheduling.

Read article
ARTICLE · 160

Half-Plane Intersection

Intersect N half-planes → convex polygon. O(N log N) via duality.

Read article
ARTICLE · 161

Hamiltonian Path

Backtracking + bitmask DP for small N.

Read article
ARTICLE · 162

Heavy-Light Decomposition

Break tree into chains so any root-to-node path crosses O(log N) chains.

Read article
ARTICLE · 163

HITS Algorithm

Kleinberg's dual model: hubs point to authorities, authorities pointed to by hubs.

Read article
ARTICLE · 164

HMAC

Key + hash → MAC. Prevents length extension attacks. Standard authentication.

Read article
ARTICLE · 165

HNSW

Multi-layer graph. Sub-log ANN queries. Powers Pinecone, Qdrant.

Read article
ARTICLE · 166

Homomorphic Encryption

Add/multiply encrypted values without decrypting. Cloud privacy compute.

Read article
ARTICLE · 167

Hopcroft-Karp

Find multiple augmenting paths per phase. Best bipartite matching bound.

Read article
ARTICLE · 168

Huffman Coding

Combine two least-frequent nodes repeatedly. Builds optimal variable-length code.

Read article
ARTICLE · 169

Hungarian Algorithm

Weighted bipartite matching in O(V³). Classical optimization.

Read article
ARTICLE · 170

Influence Maximization

Pick K seed nodes to maximize spread in social network. NP-hard, 63% approx.

Read article
ARTICLE · 171

Integer Partitions

P(n) = number of ways to write n as sum of positive integers. Euler's pentagonal recurrence.

Read article
ARTICLE · 172

Interval Graphs

Graph class with polynomial-time coloring, max clique, indep set.

Read article
ARTICLE · 173

Interval Merging + Meeting Rooms

Two classic interval problems solved by sorting + linear scan.

Read article
ARTICLE · 174

Interval Tree

Augmented BST enabling all-overlaps-with query in O(log N + K).

Read article
ARTICLE · 175

ISAP

Practical max-flow: BFS heights + gap heuristic. Often fastest.

Read article
ARTICLE · 176

Iterative Deepening DFS

DFS with increasing depth limit. Space O(d), finds shortest first.

Read article
ARTICLE · 177

Iterative DFS

Manual stack for large graphs. Same result as recursive.

Read article
ARTICLE · 178

Job Scheduling with Deadlines

Maximize profit scheduling jobs with deadlines + single machine.

Read article
ARTICLE · 179

Johnson's Algorithm

Bellman-Ford + reweighting + Dijkstra × V. Beats Floyd-Warshall on sparse graphs.

Read article
ARTICLE · 180

JWT

Signed JSON claim bundles. Ubiquitous for API auth. Common security pitfalls.

Read article
ARTICLE · 181

Karger's Min Cut

Repeatedly contract random edges. With prob ≥ 2/n², preserves min cut.

Read article
ARTICLE · 182

Karp's Minimum Mean Cycle Algorithm

Find cycle with minimum mean edge weight. O(VE).

Read article
ARTICLE · 183

K-d Tree

Partition K-dimensional space alternating axis at each level.

Read article
ARTICLE · 184

k-d Tree

Recursive space partition. NN in O(log N) expected on low dimensions.

Read article
ARTICLE · 185

Kerberos

Symmetric-key auth for enterprise networks. Foundation of Active Directory.

Read article
ARTICLE · 186

Electrical Networks + Graph Theory

Effective resistance = graph theoretic quantity. Powers many algorithms.

Read article
ARTICLE · 187

k-means Clustering

Assign points to nearest centroid, recompute centroids, repeat. O(N·k·d·iterations).

Read article
ARTICLE · 188

KMP Algorithm

Knuth-Morris-Pratt. Failure function avoids rechecking. Linear-time substring search.

Read article
ARTICLE · 189

KMP Pattern Matching

Preprocess the pattern to avoid rescanning the text. O(N + M).

Read article
ARTICLE · 190

Unbounded Knapsack

Each item may be taken any number of times. O(N × W).

Read article
ARTICLE · 191

k-Nearest Neighbors (kNN)

Predict from majority of k nearest training points. Simple non-parametric.

Read article
ARTICLE · 192

Kosaraju's Algorithm

DFS on graph + DFS on reverse graph. Two passes yield strongly connected components.

Read article
ARTICLE · 193

Kruskal's Minimum Spanning Tree

Sort edges + Union-Find gives MST in O(E log E).

Read article
ARTICLE · 194

Kth Smallest in BST

In-order traversal with early termination.

Read article
ARTICLE · 195

Kuhn's Algorithm

Simplest maximum bipartite matching. O(V·E). Interviews standard.

Read article
ARTICLE · 196

Label Propagation

Each node adopts label most common among neighbors. O(V+E) per iteration.

Read article
ARTICLE · 197

Fast Laplacian Solvers

Solve L x = b in Õ(m log n) time. Foundation of modern graph algorithms.

Read article
ARTICLE · 198

LCP Array

Longest common prefix between consecutive suffixes in sorted order. O(N) given SA.

Read article
ARTICLE · 199

Legendre + Jacobi Symbols

Generalized quadratic-residue predicates. Enable primality tests + reciprocity.

Read article
ARTICLE · 200

Levenshtein Automaton

NFA/DFA accepting words within edit distance k. Fast fuzzy search.

Read article
ARTICLE · 201

LFU Cache

Evict item with lowest access count. Complex O(1) implementation.

Read article
ARTICLE · 202

Line Segment Intersection

Find all K intersections of N segments in O((N+K) log N) via sweep line.

Read article
ARTICLE · 203

Linear Diophantine Equations

Solve ax + by = c in integers. Extended Euclidean gives all solutions.

Read article
ARTICLE · 204

Linear Regression

Predict y from X via linear model. Closed form + regularization variants.

Read article
ARTICLE · 205

Link-Cut Tree

Sleator-Tarjan structure supporting link, cut, and path queries on dynamic forest.

Read article
ARTICLE · 206

Singly Linked List

Insert, delete, search — with animation and time bounds.

Read article
ARTICLE · 207

LSH

Hash similar items to same bucket. High-dim NN in sublinear time.

Read article
ARTICLE · 208

Logistic Regression

Sigmoid + cross-entropy. Linear model for classification. Interpretable coefficients.

Read article
ARTICLE · 209

Longest Common Subsequence

Longest sequence appearing in both strings (not necessarily contiguous). O(N·M).

Read article
ARTICLE · 210

Longest Common Substring

Longest contiguous common substring. O(N+M) via SA of concatenation.

Read article
ARTICLE · 211

Longest Palindromic Subsequence

Longest subsequence (not contiguous) that's a palindrome. O(N²) DP.

Read article
ARTICLE · 212

Longest Path in DAG

Longest path is NP-hard in general graphs but polynomial in DAG. Topological DP.

Read article
ARTICLE · 213

Longest Repeated Substring

Longest substring appearing ≥ 2 times. Max LCP in suffix array.

Read article
ARTICLE · 214

Louvain Algorithm

Greedy + hierarchical merging. Standard for large-scale community detection.

Read article
ARTICLE · 215

Lowest Common Ancestor (LCA)

Recursive, binary lifting, and Euler tour + RMQ approaches.

Read article
ARTICLE · 216

LRU Cache

O(1) get + put + eviction with the classic combined data structure.

Read article
ARTICLE · 217

Lucas' Theorem

C(n, k) mod p via digit-by-digit multiplication in base p.

Read article
ARTICLE · 218

Manacher's Algorithm

Longest palindromic substring in O(N). Beats O(N²) DP.

Read article
ARTICLE · 219

Matrix Exponentiation

Compute Fibonacci-like recurrence terms in O(log N) via matrix power.

Read article
ARTICLE · 220

Matrix-Tree Theorem

Number of spanning trees = any cofactor of Laplacian matrix.

Read article
ARTICLE · 221

Max Flow

Augmenting paths + residual graph give max flow through network.

Read article
ARTICLE · 222

Maximum Flow

Push flow from source to sink until no augmenting path. Foundation of flow algorithms.

Read article
ARTICLE · 223

Max-Flow Min-Cut Theorem

Max flow = min cut. Powerful duality with applications everywhere.

Read article
ARTICLE · 224

Max Flow via Electrical Flows

Modern max flow using electrical network + Laplacian solvers.

Read article
ARTICLE · 225

Maximum Independent Set

Find largest vertex set with no edges. NP-hard, but practical algorithms exist.

Read article
ARTICLE · 226

Min-Cost Flow via Cost Scaling

Polynomial in log(max cost). Best theoretical bound.

Read article
ARTICLE · 227

Merge K Sorted Lists

PriorityQueue over K heads. Total O(N log K).

Read article
ARTICLE · 228

Merge Sort Tree

Segment tree where each node stores sorted merge of its range.

Read article
ARTICLE · 229

Merge Two Sorted Lists

Merge sorted linked lists in-place, O(N+M).

Read article
ARTICLE · 230

Miller-Rabin

Test if n is prime via Fermat-like tests. Fast + accurate.

Read article
ARTICLE · 231

Minimum Cost Arborescence

Rooted directed tree of minimum total cost. Chu-Liu-Edmonds again.

Read article
ARTICLE · 232

Min-Cost Bipartite Matching

Sub-cubic algorithms via cost scaling + push-relabel.

Read article
ARTICLE · 233

Min-Cost Max Flow

Max flow with minimum cost. Each edge has capacity + cost.

Read article
ARTICLE · 234

Layered Graph Techniques

Split graph into K layers. Enables constraint tracking via edges between layers.

Read article
ARTICLE · 235

Mo's Algorithm

Sort queries + linear pointer movement. O((N + Q) × sqrt(N)) total.

Read article
ARTICLE · 236

Möbius Function + Inversion

μ(n) enables inversion of multiplicative sums. Foundation of number theory identities.

Read article
ARTICLE · 237

Dirichlet Convolution + Multiplicative Functions

Convolution of number-theoretic functions. Möbius function inverts.

Read article
ARTICLE · 238

Modular Exponentiation

Compute aⁿ mod m in O(log n) via binary exponentiation.

Read article
ARTICLE · 239

Modularity

Q measures how much better than random the community structure is.

Read article
ARTICLE · 240

Monte Carlo Tree Search (MCTS)

Random simulations + tree expansion. Behind AlphaGo + modern game AI.

Read article
ARTICLE · 241

Morris Traversal

Threading trick lets us traverse without stack or recursion.

Read article
ARTICLE · 242

Motion Planning

Sample-based path planning in configuration space. Robotics workhorse.

Read article
ARTICLE · 243

Multi-Party Computation (MPC)

N parties compute f(x1,...,xN) without revealing inputs. Foundation of privacy-preserving compute.

Read article
ARTICLE · 244

Minimum Bottleneck Spanning Tree

MST minimizes total weight; MBST minimizes maximum edge. MST solves both.

Read article
ARTICLE · 245

Multi-Commodity Flow

K different commodities share capacity. LP-based, NP-hard variants.

Read article
ARTICLE · 246

Multi-Source BFS

Initialize BFS with all sources at distance 0. Compute distance to nearest source.

Read article
ARTICLE · 247

Multi-Dimensional Knapsack

Add weight + volume + budget → multi-dim DP.

Read article
ARTICLE · 248

N-Queens Problem

Place N queens on N×N board so none attack. Explore + prune.

Read article
ARTICLE · 249

Naive Bayes

Assume feature independence given class. Fast + surprisingly competitive.

Read article
ARTICLE · 250

Network Reliability

Given edge failure probabilities, probability s connected to t. #P-hard exact.

Read article
ARTICLE · 251

Backpropagation

Compute gradients w.r.t. all weights in O(1) forward + backward passes.

Read article
ARTICLE · 252

node2vec

Biased random walks + skip-gram. Learn continuous node representations.

Read article
ARTICLE · 253

Number of Islands

Count connected land regions. Variants: max area, distinct shapes, sinking.

Read article
ARTICLE · 254

OAuth 2.0 + OpenID Connect

Delegated authorization + authentication. Powers 'Sign in with Google/Apple'.

Read article
ARTICLE · 255

Odd Cycle Transversal

Min vertex set whose removal makes graph bipartite. NP-hard, FPT algorithms.

Read article
ARTICLE · 256

Offline Dynamic Connectivity

Answer connectivity queries with edge additions AND deletions in offline setting.

Read article
ARTICLE · 257

Order Statistic Tree

Augmented balanced BST supporting kth element + rank queries.

Read article
ARTICLE · 258

Robust Orientation Predicate

Cross product with adaptive precision. Prevents floating-point bugs.

Read article
ARTICLE · 259

PageRank

Random surfer model. Eigenvector of link matrix. Power iteration.

Read article
ARTICLE · 260

Eertree

Data structure containing all distinct palindromes. O(N) build.

Read article
ARTICLE · 261

Password Hashing

Slow, memory-hard functions defeat GPU/ASIC attackers.

Read article
ARTICLE · 262

Key Derivation Functions

Derive cryptographic keys from passwords or other keys. Standard building blocks.

Read article
ARTICLE · 263

Path Sum Problems Family

Root-to-leaf, any path, path count with sum — all one recursion pattern.

Read article
ARTICLE · 264

PCA

Find directions of max variance. Linear dim reduction + decorrelation.

Read article
ARTICLE · 265

Percolation Theory

Fluid through porous media = random subgraph connectivity. Critical thresholds.

Read article
ARTICLE · 266

Perfect Graphs

Chromatic = clique number for every induced subgraph. Polynomial coloring.

Read article
ARTICLE · 267

Perfect Squares

Lagrange's four-square theorem: always ≤ 4. DP finds exact minimum.

Read article
ARTICLE · 268

Permutations + Combinations Backtracking

Generate all permutations/combinations/subsets systematically.

Read article
ARTICLE · 269

Persistent Segment Tree

Create versioned segment trees sharing unchanged nodes. Query any historical state.

Read article
ARTICLE · 270

Piece Table

Original buffer + insertion buffer + list of pieces = fast text editing without huge copies.

Read article
ARTICLE · 271

Planar Max Flow

In planar graphs, max flow reduces to shortest path in dual graph.

Read article
ARTICLE · 272

Planarity Testing

Determine if graph can be drawn without edge crossings. O(V+E).

Read article
ARTICLE · 273

Point in Polygon

Cast horizontal ray, count intersections. Odd → inside.

Read article
ARTICLE · 274

Point-to-Line + Point-to-Segment Distance

Fundamental primitives. Cross product for line, project + clamp for segment.

Read article
ARTICLE · 275

Policy Gradient

Directly optimize policy via gradient of expected reward. Foundation of modern RL.

Read article
ARTICLE · 276

Polygon Triangulation

Simple polygon → triangles. Ear clipping O(N²), sweep-line O(N log N).

Read article
ARTICLE · 277

Populate Next Right Pointers in Binary Tree

Connect all nodes at same level using O(1) extra space.

Read article
ARTICLE · 278

Post-Quantum Hash-Based Signatures

Signatures from hash functions alone. Slower but conservative security assumption.

Read article
ARTICLE · 279

Post-Quantum Crypto

Learning With Errors problem. NIST PQC winners. Coming to TLS + SSH.

Read article
ARTICLE · 280

Post-Quantum Migration Strategy

Hybrid mode, crypto-agility, roadmap. Real deployment guidance for 2025-2030.

Read article
ARTICLE · 281

Prim's MST

Priority queue-based MST alternative to Kruskal's.

Read article
ARTICLE · 282

Prime Counting Function π(x)

Number of primes ≤ x. Meissel-Mertens O(x^(2/3)) computation.

Read article
ARTICLE · 283

Prime Factorization

Randomized factorization in O(N^(1/4)) expected. Finds small factors fast.

Read article
ARTICLE · 284

Primitive Roots + Discrete Log

Generator of ℤ*/p. Discrete log is one-way function of crypto.

Read article
ARTICLE · 285

Priority Queue via Binary Heap

Array-based heap with sift-up + sift-down. Foundation of Dijkstra, Prim, event schedulers.

Read article
ARTICLE · 286

Prüfer Sequence

Encode any labeled tree on n vertices as (n-2)-tuple. Foundation of tree counting.

Read article
ARTICLE · 287

Push-Relabel Max Flow

Excess flow + height labels. O(V²·√E) FIFO variant. Very fast in practice.

Read article
ARTICLE · 288

Quadratic Residues + Tonelli-Shanks

√a mod p. Legendre symbol for existence. Tonelli-Shanks for computation.

Read article
ARTICLE · 289

Quadtree + Octree

Divide 2D into 4 quadrants (quadtree) or 3D into 8 octants (octree) recursively.

Read article
ARTICLE · 290

R-Tree

Group nearby objects into minimum bounding rectangles hierarchically.

Read article
ARTICLE · 291

Rabin-Karp

Rolling hash slides through text. O(N+M) expected, O(NM) worst.

Read article
ARTICLE · 292

Rabin-Karp

Hash the pattern once + slide a rolling window over text. Great for multi-pattern.

Read article
ARTICLE · 293

Radix (Patricia) Tree

Trie with single-child chains compressed. Space-efficient IP routing.

Read article
ARTICLE · 294

Random Forest

N trees on bootstrap samples + random feature subsets. Robust, no-tuning ensemble.

Read article
ARTICLE · 295

Erdős-Rényi Random Graphs

G(n, p): each edge exists independently with probability p. Phase transitions.

Read article
ARTICLE · 296

Random Spanning Tree

Uniformly random spanning tree via loop-erased random walks.

Read article
ARTICLE · 297

Random Walks

Foundation of many graph algorithms. Cover time, mixing time, hitting time bounds.

Read article
ARTICLE · 298

Range Tree

Nested BSTs enable O(log^d N + K) range queries in d dimensions.

Read article
ARTICLE · 299

Red-Black Tree

The five properties that keep the tree logarithmically balanced.

Read article
ARTICLE · 300

Regex Engines

NFA construction + simulation → linear time. Backtracking → catastrophic.

Read article
ARTICLE · 301

Q-Learning

Learn action-value function Q(s, a) via Bellman updates. Foundation of DQN.

Read article
ARTICLE · 302

Reservoir Sampling

Sample k items uniformly from a stream of unknown length using only O(k) memory.

Read article
ARTICLE · 303

Reverse-Delete MST

Sort edges descending, delete each if graph stays connected.

Read article
ARTICLE · 304

Reverse a Linked List

Three-pointer iterative reverse in O(N) with O(1) extra space.

Read article
ARTICLE · 305

RNN, LSTM, GRU

Recurrent networks. LSTM/GRU solve vanishing gradient. Legacy but foundational.

Read article
ARTICLE · 306

Rod Cutting

Cut rod of length N to maximize revenue from price table. Same as unbounded knapsack.

Read article
ARTICLE · 307

Rope

Balanced binary tree of string fragments enables O(log N) insert/delete on huge strings.

Read article
ARTICLE · 308

Rotating Calipers

Sweep antipodal points around convex hull. O(N) after hull.

Read article
ARTICLE · 309

OSPF Routing

Link-state protocol runs Dijkstra on router LSDB. Foundation of IP routing.

Read article
ARTICLE · 310

RSA

Encrypt/sign via modular exponentiation. Security relies on factoring hardness.

Read article
ARTICLE · 311

Scale-Free Networks

Power-law degree distribution. Preferential attachment generates them.

Read article
ARTICLE · 312

Second-Best MST

Find MST → try replacing each MST edge with cheapest non-tree edge closing cycle.

Read article
ARTICLE · 313

Shamir's Secret Sharing

Threshold sharing: any t of n shares reconstruct secret. Information-theoretic security.

Read article
ARTICLE · 314

Segment Tree Beats

Handle 'set to min(a[i], x)' style range ops in near-O(log² N).

Read article
ARTICLE · 315

Geometric Sweep + Fenwick

Sort events, sweep, Fenwick tree for 1D counts. O(N log N).

Read article
ARTICLE · 316

Segment Tree for Geometry

Range queries on intervals + rectangles via segment tree extensions.

Read article
ARTICLE · 317

Segment Tree with Lazy Propagation

Range updates + range queries in O(log N) with deferred pushes.

Read article
ARTICLE · 318

Segment Tree

Build in O(N), query + update ranges in O(log N). Foundation of range-based DS.

Read article
ARTICLE · 319

Serialize + Deserialize Binary Tree

Convert tree to string and back. Pre-order with null markers.

Read article
ARTICLE · 320

SHA Family

Cryptographic hash functions. SHA-1 broken. SHA-2 dominant. SHA-3 different design.

Read article
ARTICLE · 321

Grid Shortest Path Variants

Grid problems with diagonals, diverse costs, teleports.

Read article
ARTICLE · 322

Shortest Path in DAG

DAG has no cycles → topological order → linear relaxation. Even with negatives.

Read article
ARTICLE · 323

Detecting Negative Cycles

V-th round improvement → negative cycle. Then trace it.

Read article
ARTICLE · 324

Shortest Path with Waypoints

Visit set of intermediate points. TSP-adjacent.

Read article
ARTICLE · 325

SSSP with Negative Edges

Bellman-Ford, SPFA, Goldberg's algo. Different trade-offs.

Read article
ARTICLE · 326

Side-Channel Attacks

Extract secrets from physical/timing behavior. Constant-time crypto defends.

Read article
ARTICLE · 327

Sieve of Eratosthenes

Classical prime sieve. O(N log log N).

Read article
ARTICLE · 328

Skip List

Multi-level linked list with random height. O(log N) with simple code.

Read article
ARTICLE · 329

Small-to-Large Merging

Always merge smaller into larger. Achieves O(N log² N) total for problems like distinct colors in subtree.

Read article
ARTICLE · 330

Small-World Networks

Short average path + high clustering. Models social + biological networks.

Read article
ARTICLE · 331

Smallest Enclosing Circle

Randomized O(N) expected. Minimum-radius circle containing all points.

Read article
ARTICLE · 332

Sort Linked List

Split, sort halves, merge. Only algorithm that beats O(N²) on linked lists.

Read article
ARTICLE · 333

Spectral Clustering

Use eigenvectors of graph Laplacian → k-means in eigenspace.

Read article
ARTICLE · 334

SPFA

Queue-based Bellman-Ford. Often 4x faster in practice, same worst case.

Read article
ARTICLE · 335

Splay Tree

Every access moves the node to the root. Amortized O(log N) with no explicit balance data.

Read article
ARTICLE · 336

Steiner Tree

MST connects ALL vertices. Steiner connects TERMINALS — can add auxiliary Steiner nodes.

Read article
ARTICLE · 337

Stern-Brocot Tree

Binary tree containing every positive rational in lowest terms exactly once.

Read article
ARTICLE · 338

Stoer-Wagner

O(V³) or O(VE + V² log V). No source-sink pair needed.

Read article
ARTICLE · 339

String Hashing

H(s) = s[0]·b^(n-1) + s[1]·b^(n-2) + ... mod p. O(1) substring hash after O(N) preprocessing.

Read article
ARTICLE · 340

Wildcard Matching via FFT

Pattern with '?' wildcards. FFT enables O((N+M) log(N+M)) match.

Read article
ARTICLE · 341

Strong Bridges + Strong Articulation Points

Directed analogs: edges/vertices whose removal disconnects the SCC structure.

Read article
ARTICLE · 342

Subset Sum Backtracking

For huge sums or non-integer values, backtracking with pruning beats DP.

Read article
ARTICLE · 343

Subset Sum

Does a subset with given sum exist? Count of such subsets? Both O(N × S).

Read article
ARTICLE · 344

Succinct Data Structures

Store trees/graphs in space close to information-theoretic minimum + constant-time queries.

Read article
ARTICLE · 345

Sudoku Solver

Fill 9×9 grid. Try digits, backtrack on constraint violation.

Read article
ARTICLE · 346

Suffix Array

Sort all suffixes. Enables substring queries. Building block of many string algos.

Read article
ARTICLE · 347

Suffix Arrays

Sorted array of all suffixes. Powers substring search + longest common substring.

Read article
ARTICLE · 348

Substring Search via Suffix Array Binary Search

Binary search sorted suffixes for pattern. O(M log N) matching.

Read article
ARTICLE · 349

Suffix Automaton

Smallest DFA recognizing all substrings of a string. O(N) construction.

Read article
ARTICLE · 350

Suffix Automaton

State machine accepting exactly substrings of S. O(N) construction.

Read article
ARTICLE · 351

DAWG

Minimized trie. Compresses shared suffixes. Compact dictionary storage.

Read article
ARTICLE · 352

Suffix Tree

Every suffix as a path from root. O(N) construction via Ukkonen's algorithm.

Read article
ARTICLE · 353

Suffix Tree

Trie of all suffixes, compressed. Ukkonen: build in O(N) online.

Read article
ARTICLE · 354

Sum of Root-to-Leaf Numbers

Each root-to-leaf path forms a number. Sum all such numbers.

Read article
ARTICLE · 355

Suurballe's Algorithm

Find two paths that don't share edges. Total cost minimized.

Read article
ARTICLE · 356

Support Vector Machines + Kernel Trick

Maximum-margin classifier. Kernel enables nonlinear via implicit high-dim mapping.

Read article
ARTICLE · 357

Symmetric Tree Check

Is a binary tree a mirror of itself?

Read article
ARTICLE · 358

t-SNE

Preserve local neighborhoods. Great for cluster visualization, misleading globally.

Read article
ARTICLE · 359

Target Sum

Assign +/- to each number to reach target. Reduces to subset sum.

Read article
ARTICLE · 360

Tarjan's SCC

Elegant O(V+E) algorithm using low-link values.

Read article
ARTICLE · 361

Temporal Graphs

Edges appear/disappear over time. Reachability, shortest paths richer.

Read article
ARTICLE · 362

Thorup's Algorithm

For undirected integer weights, achieves linear time via hierarchical structure.

Read article
ARTICLE · 363

TLS 1.3 Handshake

1-RTT handshake. ECDHE + certificate + AEAD. Modern secure channel.

Read article
ARTICLE · 364

Topological Sort

Linear ordering respecting DAG edges. Two classic algorithms.

Read article
ARTICLE · 365

Topological Sort

Two elegant ways to order a DAG. Basis of build systems, course scheduling.

Read article
ARTICLE · 366

Transformer

Encoder-decoder with self-attention. 2017 paper reshaped ML.

Read article
ARTICLE · 367

Traveling Salesman Problem

Bitmask DP: O(2^N × N²) beats brute-force O(N!).

Read article
ARTICLE · 368

Treap

BST on keys + heap on random priorities. Balance emerges from randomness.

Read article
ARTICLE · 369

Tree Diameter

Compute the diameter using height recursion.

Read article
ARTICLE · 370

Tree Isomorphism Check

Are two trees the same shape? Recursive with children permutation.

Read article
ARTICLE · 371

Tree Views

Four view problems solved with BFS + coordinate tracking.

Read article
ARTICLE · 372

Treewidth

Measures how 'tree-like' a graph is. Bounded treewidth → many NP-hard problems become linear.

Read article
ARTICLE · 373

Trie

Character-by-character tree. O(|W|) insert/search. Foundation of autocomplete + IP routing.

Read article
ARTICLE · 374

Trie (Prefix Tree)

Word storage with O(L) insert/lookup + prefix operations.

Read article
ARTICLE · 375

2-SAT via SCC

Convert clauses to implication graph, find SCCs, check consistency.

Read article
ARTICLE · 376

Union-Find with Path Compression + Union by Rank

Nearly O(1) per operation with two simple optimizations.

Read article
ARTICLE · 377

Union-Find with Rollback

Support undo. Union by rank only (no path compression). O(log N) per op.

Read article
ARTICLE · 378

Union-Find Variants

Union-Find (DSU) with path compression + union by rank gives near-O(1) amortized.

Read article
ARTICLE · 379

van Emde Boas Tree

Recursive structure achieving O(log log U) where U = universe size.

Read article
ARTICLE · 380

Vertex Cover

Any maximal matching yields 2-approx. Best-known unless P=NP.

Read article
ARTICLE · 381

Vertex Cover in Bipartite

Min vertex cover = max matching in bipartite graphs. Elegant duality.

Read article
ARTICLE · 382

Voronoi Diagram

Plane partitioned into cells, each containing points closest to a site.

Read article
ARTICLE · 383

Wavelet Tree

Recursive bit-vector partitioning enables rank/select/kth in O(log Σ).

Read article
ARTICLE · 384

Word2Vec

Learn word vectors from context prediction. 2013 breakthrough.

Read article
ARTICLE · 385

Word Search

Find word in 2D grid by adjacency. Classic DFS + backtracking.

Read article
ARTICLE · 386

Yen's Algorithm

Find not just shortest but K distinct shortest paths. Deviation-based.

Read article
ARTICLE · 387

Z-Algorithm

Z[i] = longest substring starting at i that matches a prefix. O(N).

Read article
ARTICLE · 388

Zero-Knowledge Proofs

Prove knowledge of secret without leaking it. Foundation of ZK-rollups + privacy tech.

Read article