Union Find
Operations
- Find(x): find rot/clusterId -> O(n)
- Union(x,y): merge two clusters -> O(1)
Features
- Check whether two elements are in the same set in O(1)
- Optimization:
- Path Compression: make tree flat -> happen during Find()
- Union by rank: merge low rank tree to high rank tree