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 same?] --Yes--> [Already connected]
|
No
|
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. Repeat finds and unions to manage connected groups.
