Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write C + + code of this algorithm Prim's Algorithm: Prim's algorithm works differently from Kruskal ' s . It builds a minimum spanning tree
Write code of this algorithm
Prim's Algorithm: Prim's algorithm works differently from Kruskal s It builds a minimum spanning
tree by expanding outward in connected links from some vertex. One edge and one vertex are
added at each stage. The edge added is the one of least weight that connects the vertices already in
with those not in and the vertex is the endpoint of this edge that is not already in
This algorithm involves the following steps.
i Choose any vertex of
ii Choose an edge of such that and has the smallest weight among
the edges of incident with
iii If edges dots, have been chosen involving end points dots, choose an edge
with dots, and dots, such that has the smallest
iv Stop after edges have been chosen. Otherwise, repeat Step
A step by step illustration of Prim's Algorithm to find a minimal spanning tree of the graph given
Example Figure is given below.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started