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
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 always forms a subtree, and is chosen to be the set of this tree's vertices. On each iteration, the subtree defined by grows by one edge, namely the lightest edge between a vertex in and a vertex outside Draw a table to show the changes of cost and prev values, and construct the final Minimum Spanning Tree. What is the main difference between the Dijkstra's algorithm and the Prim's algorithm.
procedure prim
Input: A connected undirected graph with edge weights
output: A minimum spanning tree defined the array prev
for all uinV :
prev
pick any initial node
makequeue queue, using costvalues keys
while not empty:
deletemin
for each :
:
prev
decreasekey
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
