Prim's Algorithm
Prim grows one tree by adding the cheapest edge that leaves the tree. A binary heap stores the candidate edges.
Costs
| Category | Algorithm |
| Difficulty | Hard |
| Binary heap | O((V + E) log V) |
| Result | a minimum spanning tree on a connected graph |
| Compared with Kruskal | often 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.