Union-Find
find identifies the set representative.
union merges two sets.
Path compression flattens find paths.
Union by rank or size controls tree height.
Amortized complexity is O(alpha(n)), effectively constant for practical sizes.
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.