algo·visual

Kruskal's MST

Graphs
avgO(E log E)worstO(E log E)spaceO(V + E)
43568782549371ABCDEFGH

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)

Search algorithms

Jump to any algorithm or page