next up previous


CSE 2320 Section 501/571 Fall 1999

Homework 5

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

1.
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.

\psfig{figure=figures/h51.ps}

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

\psfig{figure=figures/h52.ps}

(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.

3.
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.

\psfig{figure=figures/h53.ps}

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

\psfig{figure=figures/h54.ps}

5.
Compute the Knuth-Morris-Pratt prefix function $\pi$ for the following patterns when the alphabet is $\Sigma = \{ {\tt a}, {\tt b}, {\tt
c} \}$.

(a)
abccbabbcaabcbabccbabcba

(b)
aaaaaaaabbbbbbbbaaaaaaaa

6.
Determine a possible pattern (if any) consistent with the following KMP prefix functions when the alphabet is $\Sigma = \{ {\tt a}, {\tt b}, {\tt
c} \}$.

(a)

i 1 2 3 4 5 6 7 8
$\pi[i]$ 0 1 2 3 0 1 0 1

(b)

i 1 2 3 4 5 6 7 8
$\pi[i]$ 0 1 2 1 2 1 2 1

(c)

i 1 2 3 4 5 6 7 8
$\pi[i]$ 0 0 0 1 1 0 0 0


next up previous