Overview - Minimum Spanning Tree Kruskal's Algorithm
What is it?
Kruskal's algorithm finds the Minimum Spanning Tree (MST) of a weighted undirected graph — a subset of edges that connects all vertices with minimum total weight and no cycles. It works by sorting all edges by weight, then greedily adding edges that don't create cycles using Union-Find (Disjoint Set Union).
Why it matters
Kruskal's demonstrates two powerful concepts together: greedy algorithm design and the Union-Find data structure. The greedy proof (always take the minimum safe edge) is elegant and non-obvious. Union-Find's path compression and union by rank achieve near-O(1) per operation, making Kruskal's O(E log E) — dominated by the sort.
Where it fits
You need comfort with C structs, arrays, qsort, and the concept of a spanning tree before tackling this. After mastering it, Prim's algorithm, Dijkstra's algorithm, and network flow problems follow naturally.