Disjoint Set Union/Find†More Formally
Given a set U = {a1, a2, … , an}
Maintain a partition of U, a set of subsets of U {S1, S2, … , Sk} such that:
- each pair of subsets Si and Sj are disjoint:
- together, the subsets cover U:
- each subset has a unique name
Union(a, b) creates a new subset which is the union of a’s subset and b’s subset
Find(a) returns a unique name for a’s subset
†AKA the dynamic equivalence problem