Ask a question from expert

Ask now

Prim’s Algorithm:.

2 Pages253 Words296 Views
   

Added on  2019-10-18

Prim’s Algorithm:.

   Added on 2019-10-18

BookmarkShareRelated Documents
Prim’s Algorithm: This algorithm is used to find minimum cost spanning tree. This algorithm uses greedy approach.Prim’s algorithm treats each node in the given graph as single tree and search for less weighted edge. Here are some steps that are followed using this algorithm,1.First all loops (self-loops) are removed and parallel edges.2.Choose an arbitrary node as root node randomly.3.Checking outgoing edges and select the one with less cost or less weight.4.And the process in the point 3 will be continued until we reach at the end of the given undirected graph. Through this method we will get a spanning tree with the shortest part.Pros:This algorithm is faster than the Brute Force.Cons:This algorithm may not give optimal solution in comparison of Brute Force Algorithm.Brute Force AlgorithmHere are some steps,1.According to this algorithm we first list all possible Hamilton circuits ( means learning out the exact reversals, if you wish )2.Then calculate weight of each circuits3.Choose the one with the smallest weight.Pros:This algorithms always work if there is enough time and care.Easy to understand and implement. It can give an optimal (best) solution.
Prim’s Algorithm:._1

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Minimum Spanning Tree Question 2022
|6
|614
|23