Union-find and Kruskal's MST, step by step
10 steps · about 3 h 7 min · Intermediate
- Union Find Introduction (video, William Fiset (YouTube), 10 min)
It starts with the problem union-find solves: tracking which elements belong to the same group.
- Kruskal's algorithm, minimum spanning trees (article, algorithms-visual.com, 20 min)
It walks through Kruskal's algorithm with pictures, so you see how find and union reject cycle-forming edges.
- Minimum Spanning Tree (Prim's, Kruskal's) - VisuAlgo (interactive, VisuAlgo, 20 min)
You can run Kruskal's algorithm on your own graphs and watch the union-find checks happen.
- Union Find Kruskal's Algorithm (video, William Fiset (YouTube), 10 min)
It ties the data structure back to the MST algorithm in a short worked example.
- Union Find Path Compression (video, William Fiset (YouTube), 10 min)
It explains the key optimisation that keeps find fast, before you write any code.
- Disjoint Sets Visualization (interactive, David Galles' visualization (mirror), 15 min)
You can experiment with union by rank and path compression and see the trees flatten.
- Union Find Code (video, William Fiset (YouTube), 12 min)
Once the ideas are clear, you can follow a full implementation line by line.
- Minimum Spanning Tree - Kruskal with Disjoint Set Union (reference, cp-algorithms.com, 20 min)
It gives compact working code and the O(M log N) running-time argument.
- williamfiset/algorithms (repo, GitHub (William Fiset), 25 min)
You can read and run a well-tested union-find and Kruskal implementation in code, to compare with your own.
- 15-451: Algorithm Design and Analysis, Union-Find (article, Carnegie Mellon University, 45 min)
It closes with the amortized-cost analysis of why union-find is nearly constant time.