Kruskal's MST
GraphsavgO(E log E)worstO(E log E)spaceO(V + E)
Each of the 8 nodes starts in its own set: it is its own parent
1 / 22
Nodes8
Source
Edgesweights 1 to 99
How it works
Kruskal's algorithm considers edges from lightest to heaviest and keeps each one that joins two different components, skipping any edge that would close a cycle. A union-find structure answers "are these already connected?" in near-constant time, so sorting the edges dominates the cost.
Complexity
- Best
- O(E log E)
- Average
- O(E log E)
- Worst
- O(E log E)
- Space
- O(V + E)