a.
A Minimum Spanning Tree in an undirected connected weighted graph is a spanning tree of minimum weight (among all spanning trees).Â
Prim’s Algorithm :
Start by picking any vertex to be the root of the tree.
While the tree does not contain all vertices in the graph find shortest edge leaving the tree and add it to the tree.
MST: "\\{\\{A,B\\},\\{B,C\\},\\{C,E\\},\\{E,H\\},\\{E,G\\},\\{H,F\\}\\}"
WEIGHT=46
b.
Kruskal's algorithm to find the minimum cost spanning tree uses the greedy approach. This algorithm treats the graph as a forest and every node it has as an individual tree. A tree connects to another only and only if, it has the least cost among all available options and does not violate MST properties.
Add the edge which has the least weightage:
"\\{B,C\\},\\{B,A\\},\\{A,F\\},\\{A,G\\},\\{F,H\\},\\{H,E\\},\\{C,D\\}"
Comments
Leave a comment