← Union-Find & MST · guided lesson

Union-Find & Minimum Spanning Trees

1 / 18 · story

the story

Union-Find (Disjoint Set Union)

Every tool here exists because something was too slow or broke without it. Here is what.

1964 (analysed 1973–75) · Bernard A. Galler & Michael J. Fischer; analysis by John Hopcroft & Jeffrey Ullman, and Robert Tarjan

In 1964 Galler and Fischer published a three-page CACM paper on a compiler chore: FORTRAN's EQUIVALENCE statements say which variables share memory, and the compiler must group them. Their idea was to store each group as a tree, finding every group in one scan of the declarations — cutting computation time by 40% compared with the method published before it. Why it is so fast took another decade: Hopcroft and Ullman (1973) proved an O(log* n) bound, and Tarjan (1975) pinned it to the inverse Ackermann function α(n). In 1989 Fredman and Saks proved that, in the cell-probe model, no structure can beat α(n) amortized per operation.

the problem it solved

Grouping things that are declared equal pair by pair, and answering "same group?" without re-scanning everything.

why it matters: without it

Every "are these connected yet?" question would mean a fresh BFS/DFS over the whole graph — fine once, hopeless after each of millions of updates.

sources: Galler & Fischer — An improved equivalence algorithm (CACM, 1964) ↗ · Hopcroft & Ullman — Set Merging Algorithms (SIAM J. Computing, 1973) ↗ · Tarjan — Efficiency of a Good But Not Linear Set Union Algorithm (JACM, 1975) ↗ · Fredman & Saks — The cell probe complexity of dynamic data structures (STOC, 1989) ↗

also in this chapter: Minimum spanning tree (and the cut property) · Kruskal's algorithm · Prim's algorithm (Jarník–Prim)