Step 1: Sort
Begin by sorting all edges of the graph in non-decreasing order of their weight.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A greedy algorithm that finds the Minimum Spanning Tree by sorting all edges and adding them if they don't form a cycle. It's a forest-growing approach using Disjoint Set Union.
Begin by sorting all edges of the graph in non-decreasing order of their weight.
Pick the smallest edge. Check if adding it forms a cycle with the spanning tree formed so far.
Use Disjoint Set Union (DSU) to check if nodes are in the same component. If they aren't, add the edge!
Repeat until there are (V-1) edges in the MST, where V is the number of vertices.