CPSC 327 Data Structures and Algorithms Spring 2024

Homework 12
due Wed 3/6 in class

  1. Find the cut vertices in the graph shown to the right.

    Start the DFS from A, and show your work tracing the algorithm by identifying the tree and back edges in the DFS tree and by giving the entry labels and earliest reachable ancestor for each vertex. When there is a choice of what vertex to consider next, use alphabetical order.

    The example below illustrates a convenient way of showing your work. The entry times are shown in black and the earliest reachable ancestors in red in order to distinguish them. An alternative is to list entry times and earliest reachable ancestors in a table.


  2. Perform a topological sort on the graph shown to the right, giving the resulting order of vertices.

    Show your work tracing the algorithm by giving the exit labels computed for each vertex. When there is a choice of what vertex to consider next, use alphabetical order.


  3. [corrected!] Carry out the Bellman-Ford algorithm on the graph shown to the right. (Negative weights are shown in red to make them easier to identify.) For clarity, when there are edges (u,v) and (v,u) with the same weight, a single undirected edge is shown.

    Go through the edges in alphabetical order. (Be sure to consider both directions --- such as AB and BA --- for the undirected edges.)

    Show your work tracing the algorithm by giving a table of the dist labels as they are updated in each iteration of the repeat loop. (Have a column of the table for each vertex and a row for each iteration.)


For the MST algorithms, break ties by alphabetical order — take an edge's name as its endpoint vertices in alphabetical order, then compare the edge names. For example, the two weight-5 edges incident on vertex C in the graph shown would be named BC and CD, and BC should be chosen first.

  1. Carry out Kruskal's algorithm on the graph shown to the right. Show your work tracing the algorithm by listing the MST edges in the order they are added to the MST.

  2. Carry out Prim's algorithm on the graph shown to the right. Show your work tracing the algorithm by listing the MST edges in the order they are added to the MST.