Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions