Kruskal's Algorithm Concept & Pattern
Original12/26/25Less than 1 minute
Union Find + Greedy Algorithm
Algorithm steps
- Sort all edges by the order of its weight ascendingly;
- Create MST set;
- Loop from the edge of smallest weight. If this edge won't construct a cycle with other edges in the MST set, it is definitely a part of MST, then add it into MST; otherwise it's not;
- After 3, if there is only one connected component, there exists a minimal spanning tree; otherwise no spanning tree.
Time complexity:
- Sort: , Union Find:
Space complexity:
