Concept Flow - Union Find Disjoint Set Data Structure
[Initialize each element as its own set]
|
v
[Find root of element A] ←─────┐
| |
v |
[Find root of element B] |
| |
v |
[Are roots different?] --No--> [Stop]
|
Yes
|
v
[Union sets by linking roots]
|
v
[Update parent pointer]
|
v
[Done]Start with each element alone. To union, find roots of both sets. If different, link one root to the other. This merges sets.