Union-Find

A structure built for exactly two moves: finding which group an item belongs to, and merging two groups, each in near-constant time.