Union-Find groups elements into disjoint sets and answers “are x and y in the same group?” in near-constant time (inverse Ackermann). Use it for connected components, redundant edges, accounts merge, percolation, friend circles.
Redundant Connection: union each edge; the first edge whose endpoints are already connected is redundant.
Accounts Merge: union emails by shared account; gather per root.
Number of Provinces: union on adjacency; count distinct roots.
find(x) -> root
union(a, b): connect roots unless already same
connected(x, y)? -> find(x) == find(y)
Union-Find for disjoint-set merges. Use DFS/BFS only when you need the path.