Loading algorithms…
Loading visualizer…
Disjoint Set Union with path compression and union by rank. Near-constant time connectivity queries.
Build three pairs, query connectivity, then merge components with union(1,2).
| i | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| parent | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| rank | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Disjoint Set Union with path compression and union by rank. Near-constant time connectivity queries.