Prim's Algorithm Time Complexity O(N^2)
Prim's Algorithm Time Complexity O(N^2) . Decrease key operation is performed to change the value of distance in every iteration. Let g be an undirected connected graph with distinct edge weights. Prim's Algorithm on minimum spanning tree from www.slideshare.net As it will be carried out n−1 times, that gives a total of o(n 2) time. In computer science, prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. In prim's algorithm for every vertex you have to search for all the adjacent vertices which can be o (n) in worst case and search for minimum among them takes o (n) time.