Workspace Lab Network Merge
0d
Back to questionsDSA Visualizers: 388 Coding Questions

Disjoint-set union visualizer

Connect stations using disjoint sets and union by size.

Network merge

For each link, find both representatives and choose the larger root. If sizes tie, choose the first endpoint’s root.

Link4 → 3
Components5
Operations0
0Root · 1
1Root · 1
2Root · 1
3Root · 1
4Root · 1
Parent array
01234
01234

Step 0 · Connect all stations with union by size.

Union by size attaches the smaller tree to the larger. Without path compression, root lookup is O(log n).

Play this game

Continue learning

Practice related DSA questions in the same topic.