21.11.2014 Views

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

CHAPTER 25 Weighted Graphs and Applications Objectives • To ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4. Dijkstra’s algorithm starts search from the source vertex <strong>and</strong> keeps finding vertices that have the<br />

shortest path to the source until all vertices are found.<br />

Quiz<br />

Do the quiz for this chapter online at www.cs.armstrong.edu/liang/cpp3e/quiz.html.<br />

Programming Exercises<br />

<strong>25</strong>.1* (Kruskal’s algorithm) The text introduced Prim’s algorithm for finding a minimum spanning tree.<br />

Kruskal’s algorithm is another well-known algorithm for finding a minimum spanning<br />

tree. The algorithm repeatedly finds a minimum-weight edge <strong>and</strong> adds it to the tree if it<br />

does not cause a cycle. The process ends when all vertices are in the tree. Design <strong>and</strong><br />

implement an algorithm for finding a MST using Kruskal’s algorithm.<br />

<strong>25</strong>.2* (Implement Prim’s algorithm using adjacency matrix) The text implements Prim’s algorithm using<br />

priority queues on adjacent edges. Implement the algorithm using adjacency matrix for<br />

weighted graphs.<br />

<strong>25</strong>.3* (Implement Dijkstra’s algorithm using adjacency matrix) The text implements Dijkstra’s algorithm<br />

using priority queues on adjacent edges. Implement the algorithm using adjacency matrix<br />

for weighted graphs.<br />

<strong>25</strong>.4* (Modify weight in the nine tail problem) In the text, we assign the number of the flips as the weight<br />

for each move. Assuming that the weight is three times the number of flips, revise the<br />

program.<br />

45

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!