Assignment 05 - Prim vs Dijkstra (Solution)

Assignment 05 - Prim vs Dijkstra (Solution) - di²erent...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP 271: Design and Analysis of Algorithms Fall 2007 Solution to Assignment 5 Question 1 : Consider running Prim’s MST algorithm and Dijkstra’s single- source shortest path algorithm on the graph shown below. For Prim’s algorithm, ignore edge orientation and start from vertex s . For Dijkstra’s algorithm, use s as the source vertex. Then the two algorithm result in exactly the same tree. 1. Show the tree (without showing the process of ±nding it). 2. Modify the edge weights so that the two algorithms produce two
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: di²erent trees. Show the trees produced. (Hint: You can do this by changing the weight of one edge.) s a b c d 7 2 3 8 9 6 5 1 Solution: (a) Tree produced by both Prim’s and Dijkstra’s algorithm is as follows. s a b c d 7 2 3 8 9 6 5 1 1 (b) Modifed graph: s a b c d 7 2 3 8 9 4 5 1 (i) Tree produced by Prim’s algorithm For the modifed graph s a b c d 7 2 3 8 9 4 5 1 (ii) Tree produced by Dijkstra’s algorithm s a b c d 7 2 3 8 9 4 5 1 2...
View Full Document

Page1 / 2

Assignment 05 - Prim vs Dijkstra (Solution) - di²erent...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online