Prim's Minimum Spanning Tree (MST) algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. A minimum spanning tree is a subset of the edges that connects all vertices with the minimum possible total edge weight, without forming any cycles. The algorithm starts with a single vertex and gradually expands the tree by adding the smallest edge that connects a vertex in the tree to a vertex outside of it. This process continues until all vertices are included in the tree.
The algorithm can be summarized in the following steps:
Prim's algorithm is efficient, typically running in time when implemented with a priority queue, making it suitable for dense graphs.
Start your personalized study experience with acemate today. Sign up for free and find summaries and mock exams for your university.