CSE 2320 Section 501 Fall 1998

Homework 5

Due: December 3, 1998, in class (December 4, 1998, 5:00pm for -10%)

1.
Following Figure 23.3 on page 471, execute the breadth-first search procedure on the graph below starting at vertex a. Specifically, show the graph and the contents of the queue Q each time line 9 of the BFS procedure is executed. In addition to the vertex label, show the distance value for each vertex. Shade the predecessor edges added to the breadth-first tree during the course of execution. You do not have to show the colors of the vertices.

2.
Execute TOPOLOGICAL-SORT on the following graph by labeling the vertices with the starting and finishing times produced by depth-first search, and listing the vertices in topological order. Consider vertices in alphabetic order when iterating over a set of vertices.

3.
Execute STRONGLY-CONNECTED-COMPONENTS on the following graph.

(a)
Label the vertices of the above graph with the starting and finishing times produced by the first call to depth-first search, considering vertices in alphabetic order when iterating over a set of vertices.

(b)
Show the transpose of the above graph.

(c)
Label the transpose graph with the starting and finishing times produced by the second call to depth-first search, considering vertices in the proper order.

(d)
Show the strongly-connected components of the original graph.

4.
Following Figure 24.5 on page 508, execute the MST-PRIM procedure on the following graph and show the final minimum spanning tree. Use vertex a as the root vertex and consider vertices in alphabetical order.

5.
Following Figure 27.6 on page 595, show the execution of the Edmonds-Karp algorithm on the following flow network.

6.
Compute the Knuth-Morris-Pratt prefix function for the following patterns when the alphabet is .

(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

(b)
abcabcabcabcabcabcabcabcabcabc

(c)
abcabccbacbaabcabccbaabcbcaaab

7.
Determine a possible pattern consistent with the following KMP prefix functions when the alphabet is .

(a)

 i 1 2 3 4 5 6 0 1 0 0 0 0

(b)

 i 1 2 3 4 5 6 7 8 9 10 0 0 0 0 0 0 1 1 2 3

(c)

 i 1 2 3 4 5 6 7 8 9 10 11 0 1 2 0 1 2 3 0 1 2 3