Skip to main content

Minimum Spanning Tree - Kruskal's

Learn Minimum Spanning Tree - Kruskal's (Graphs, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Building an MST by Sorting Edges Globally Unlike Prim's (which grows from one vertex), Kruskal's sorts ALL edges by weight ascending, then greedily adds each edge UNLESS it would create a cycle - checked in O(α(n)) using Union-Find. The result is always a valid MST once V-1 edges have been added.

More lessons in Graphs