Midterm I (EX1) Review Questions


  1. Give a pseudocode description of the graph search algorithm.

  2. What kind of dispenser do you use for a depth-first search? A breadth-first search? A prioritized search?

  3. In a graph search, the dispenser contains directed edges. Could the source (from) vertex of an edge in the dispenser be a visited vertex? An unvisited vertex? Could the destination (to) vertex of an edge in the dispenser be a visited vertex? An unvisited vertex?

  4. Suppose that you stop a graph search at some point and check which vertices are visited and which are not visited. Based on this information are there any edges that you can be sure are in the dispenser?

For the next four problems use a graph described as follows. There are eight vertices in two rows, four vertices in each row. The vertices in the first row are, from left to right, a, b, c, and d. The vertices in the second row are, from left to right, e, f, g, and h.

There is an edge between each vertex and its immediate neighbors above, below, to the left, or to the right. In addition there is one diagonal edge between vertices c and f.

When edge lengths are required, the lengths of the edges in the top row are, from left to right, 6, 5, and 7. The lengths of the edges in the bottom row are all 8. The lengths of the vertical edges are, from left to right, 9, 7, 4, and 6. The diagonal edge has length 5.

For the searches below, when you iterate the edges leaving a vertex, do so in alphabetic order. Shade in the via edges for the search and number them in the order (starting with 1) that they are retrieved from the dispenser.

  1. Do a breadth-first search of the graph starting at vertex a.

  2. Do a depth-first search of the graph starting at vertex a.

  3. Find a minimal spanning tree for the graph using a search starting at vertex a.

  4. Find a shortest paths spanning tree for the graph starting at vertex a.

  5. How are edges prioritized in a minimal spanning tree search?

  6. How are edges prioritized in a single-source shortest paths search?

  7. What two Java classes can be used as iterators? What methods can you use with them? What do the methods do?

  8. What is the primary difference between dispensers and table data structures?

  9. How do you find an augmenting path for a network flow algorithm? What do you do with the path in preparation for another step of the algorithm?

  10. Alice, Bill, Chuck, and Dianne are driving a train around the country. They need to assign themselves four roles for the trip: breakman, cook, engineer, and fireman. Alice and Bill can fill the role of breakman. Alice and Chuck are both great cooks. Bill, Chuck, and Dianne all know how to be engineers. Bill and Dianne can do the work of a fireman. Use the network flow algorithm to find a suitable assignment of roles for Alice, Bill, Chuck, and Dianne. Show a step for each augmenting path. Be sure to indicate the solution.

  11. You are working the Floyd-Warshall algorithm to find the shortest distance between all pairs of vertices. You have so far considered shortest paths that allow vertices a, b, c, and d as intermediate vertices. At this point, you have the following distance matrix.
    abcde
    a05467
    b50793
    c47023
    d69201
    e73310
    The last step of the algorithm allows vertex e to also be used as an intermediate vertex in a path. Describe how you compute the new entry in row b and column d.

  12. What is the run time for the Single-Source Shortest Paths algorithm?

  13. What is the run time for the Floyd-Warshall algorithm?

[an error occurred while processing this directive]