Hard

Prim's Algorithm

Prim grows one tree by adding the cheapest edge that leaves the tree. A binary heap stores the candidate edges.

Costs

CategoryAlgorithm
DifficultyHard
Binary heapO((V + E) log V)
Resulta minimum spanning tree on a connected graph
Compared with Kruskaloften better on dense graphs

Questions

What is Prim's Algorithm?

Prim grows one tree by adding the cheapest edge that leaves the tree. A binary heap stores the candidate edges.

Where do I practice it?

DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.