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 |
[Compare roots] -- Same? -- Yes --> [Already connected, do nothing]
|
No
|
v
[Union sets by linking roots]
|
v
[Update parent pointers]
|
v
[Done]Start with each element alone. To union, find roots of both sets. If roots differ, link one root to the other to merge sets.
