Slideshow

Monday 25 February 2013


Write Kruskal’s algorithm and give the analysis. Compare it with Dijkstra’s
method. 

Ans:
Kruskal’s Algorithm for minimum cost spanning tree
1. Make the tree T empty.
2. Repeat steps 3, 4 and 5 as long as T contains less
than n-1 edges and E not empty; otherwise proceed to step 6.
3. Choose an edge (v,w) from E of lowest cost.
4. Delete (v,w) from E.
5. If (v,w) does not create a cycle in T then add(v,w) to T
else dicard(v,w).
6. If T contains fewer than n-1 edges then print (‘no spanning

No comments:

Post a Comment