Question: 8 . As shown in the following figures, Prim's algorithm is usually used to find the minimum spanning tree, in which the intermediate set of

8.As shown in the following figures, Prim's algorithm is usually used to find the minimum spanning tree, in which the intermediate set of edges x always forms a subtree, and S is chosen to be the set of this tree's vertices. On each iteration, the subtree defined by x grows by one edge, namely the lightest edge between a vertex in S and a vertex outside S.(1) Draw a table to show the changes of cost and prev values, and construct the final Minimum Spanning Tree. (12')(2) What is the main difference between the Dijkstra's algorithm and the Prim's algorithm. (3')
procedure prim (G,w)
Input: A connected undirected graph G=(V,E) with edge weights we
output: A minimum spanning tree defined by the array prev
for all uinV :
cost(u)=
prev(u)=n11
pick any initial node wo
cost(u0)=0
cost(u0)=0
H= makequeue (V)(priority queue, using cost-values as keys)
while His not empty:
v=deletemin(H)
for each {v,z}inE:
ifcost(z)>w(v,2):
cost(z)=w(v,z)
prev(z)=v
decreasekey (H,z)
 8.As shown in the following figures, Prim's algorithm is usually used

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!