SOARDO
Software Engineer (SDE)dsaadvanced3 interactive MCQs in app

Minimum Spanning Tree: Kruskal & Prim

Kruskal sort-edges + Union-Find cycle avoidanceexactly V-1 edges in an MSTMST total weight vs Dijkstra single-source distance

A Minimum Spanning Tree (MST) connects all `V` vertices of a connected undirected weighted graph using exactly `V - 1` acyclic edges with minimum total weight. **Kruskal’s algorithm** sorts edges by weight ascending (`O(E log E)`) and greedily adds an edge via Union-Find iff it connects two different components (`find(u) != find(v)`). **Prim’s algorithm** grows from one start node via min-heap (`O(E log V)`), great for dense graphs!

sorting edges `(A,B,1), (A,C,2), (C,D,3), (B,C,4)` picks `(A,B), (A,C), (C,D)` (`weight = 6`) and skips `(B,C,4)` since `B` and `C` already share a component!
confusing Shortest Path Tree (Dijkstra: min distance from root to each node) with MST (min TOTAL sum of tree edges connecting all nodes).
Minimum Spanning Tree — GeeksforGeeksread ↗Minimum Spanning Tree: Kruskal & Prim — Applied Practicepractice ↗VisuAlgo Interactive Visualizationsvisualize ↗NeetCode DSA Roadmappractice ↗

Practice Minimum Spanning Tree: Kruskal & Prim with 3 graded MCQs & written feedback.

Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.

Test yourself free on SOARDO →View full Software Engineer roadmap

More Software Engineer Study Guides