+1 (845) 317-8489 [email protected]

Learning Goal: I’m working on a algorithms & data structures question and need support to help me learn.

Prims Algorithm is an algorithm to find minimum spanning tree. It is a greedy apporach which means you are greedy for something good for a short term This approach is known as Greedy Approach. The cost of the spanning tree is a sum of the weights of all the edges in the tree. Minimum spanning tree that where minimum cost is involved is a tree with minimum cost involved Now we have a spanning tree which spans every node. The Cost of MST = 1+2+3 = 6 6 would be the cost minimum spanning tree here So this I got this Minimum Spanning Tree with the help of Prims. can do everything So here we grow spanning tree from the starting position in Prims Algorithm. Prims Algorithm helps us to get this type MST. The Prims algorithm is used to calculate the type of MST using the Prims Algorithm. We ‘ll see an important example here and give an idea of how you can apply Prims. Algorithm.

I have an option of 1-2 whose cost was 20 already Can I connect 1 to any node ? No Can i connect 6 to any nodes ? Yes i can conncet 6 to 5 The cost would be 18 I ca n’t see any other option Neither could I connect any nodes form A to that of V nor 6 in V Now i could see only 2 options One is 1-1 and the other is 6-5 since the cost is less. So 5 would be removed from V and the rest would be the same And A would be 1,5 and 6. V only has 0 And A has 1,2,3,4,5 and 6 These are my elements of A Now if I talk about options here What options do I have now ? Can I connect 1 with any other node ? Let us start from 0 and see it from V I have to connect a node from A to V Or from V to A Or from either of the sides Since V has lesser node I ‘ll start from here which node can be connected 1 with ? Can 1 be connected to either 0 or 2 ? No we ca n’t connect any node with 6 Minimum cost is 4-3 and We ‘ll reject this and choose 4 -3 since it ‘s cost Answer in the comments the cost of the MST of graph G in the comment section. I hope you understood the Prims Algorithm Maintain V and A. If you do it by yourself then it would be difficult for the others to understand your steps How we got this MST ? If you show all the subsequent values of A and V. So you ‘ll clearly know how you got this I hope everybody understood Prims.