## Prim’s Complexity

Prim’s algorithm starts by selecting the least weight edge from one node. In a complete network there are edges from each node. At step 1 this means that there are comparisons to make.

Having made the first comparison and selection there are unconnected nodes, with a edges joining from each of the two nodes already selected. This means that there are comparisons that need to be made.

Carrying on this argument results in the following expression for the number of comparisons that need to be made to complete the minimum spanning tree:

The result is that Prim’s algorithm has cubic complexity.