Tutorial 15, CPSC 331, Fall 2008

home page -  news -  syllabus -  schedule -  assignments -  tutorials -  tests -  java -  references -  Mike Jacobson


Tutorial 1 -  Tutorial 2 -  Tutorial 3 -  Tutorial 4 -  Tutorial 5 -  Tutorial 6 -  Tutorial 7 -  Tutorial 8 -  Tutorial 9 -  Tutorial 10 -  Tutorial 11 -  Tutorial 12 -  Tutorial 13 -  Tutorial 14 -  Tutorial 15 -  Tutorial 16

 Graph Traversals and Minimum Cost Paths

About This Exercise

This exercise is based on the information about graph algorithms introduced in lectures on November 24, November 26, November 28, and December 1.

The objectives of this exercise are

Please read through and try to solve the problems on this exercise before attending the tutorials during the last week of classes. The problems on this exercise will be discussed during these tutorials.

Problems

  1. Trace the execution of DFS(G, 0) on each of the following graphs G.

    1.  

      An Undirected Graph

    2.  

      Another Undirected Graph

  2. Trace the execution of BFS(G, 0) on each of the graphs given in the previous question.

  3. Trace the execution of MCP(G, 0) on each of the following weighted graphs.

    1.  

      A Weighted Graph

    2.  

      Another Weighted Graph

    3.  

      Yet Another Weighted Graph

    4.  

      A Final Weighted Graph

  4. Implement each of the DFS, BFS, and MCP algorithms as Java programs.

    Note that you will have to examine the information about “data structures” included in the notes on “Minimum Cost Paths,” and you will need to design your program carefully, if the worst-case running time of your program is to be as small as the lecture notes suggest!

    If you do not have time to solve this problem then, at least, you should study the online notes and try to describe those things that you would need to do in order to make sure that your program is efficient.

  5. As discussed in lectures there will generally be more than one depth-first search tree corresponding to a given undirected graph G and vertex s. Why is that the case?

    Is this true for breadth-first search trees and minimum-cost paths, as well? Why (or why not)?

    On the other hand, some of the other information that some of these algorithms compute is unique. Which is information is this, and why is it unique?

  6. Finally, modify the MCP algorithm so that it can be used to find the minimum-cost paths from a given vertex s to all other (reachable) vertices, in a weighted directed graph.

    Describe any and all modifications that must be made to the analysis of the algorithm, in order to prove that your algorithm for directed graphs is correct and efficient.

    Then, if time permits, trace the execution of your program on the following weighted directed graph, using 0 as the start vertex.

     

    A Weighted Directed Graph


This page last modified:
http://www.cpsc.ucalgary.ca/~jacobs/cpsc331/F08/tutorials/tutorial15.html