Disjoint Set

Basic idea

Union-find: tracks a partition of a set under merge (union) and lookup-root (find). With union-by-rank plus path compression, both operations run in inverse-Ackermann amortised time — essentially constant.

Key formulas

Resources

Siblings