Minimum Spanning Tree (Kruskal's Algorithm)
7 min read.
Visualize Kruskal's MST algorithm: sort all edges by weight, then greedily add the cheapest edges that don't create a cycle using Union-Find. Demonstrates why a greedy approach guarantees a minimum spanning tree on connected graphs.
Think of it this way: Imagine connecting all houses in a neighborhood with water pipes. You want to use the minimum total pipe length while ensuring every house gets water. MST finds the cheapest way to connect everyone.
Sort the 7 edges by weight: 1, 2, 3, 4, 5, 6, 7.
Check your understanding
Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.
Kruskal’s algorithm
Order the steps of building a minimum spanning tree.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
- 1Drop a step here
- 2Drop a step here
- 3Drop a step here
- 4Drop a step here
- 5Drop a step here
Quiz
20 questionsWhen is Kruskal preferred over Prim?
Done with this lesson?
Sign in free to keep your progress, streak and quiz scores.