CMPS 101
Summer 2009
Midterm Exam 2
Solutions
1.
(20 Points)
Let
G
be a directed graph.
Determine whether, at any point during a Depth First Search of
G
, there can exist an edge of the following kind.
No justification is required.
(See last page for DFS
pseudocode.)
a.
(4 points)
A tree edge which joins a gray vertex to a black vertex.
Yes
b.
(4 Points)
A tree edge which joins a black vertex to a white vertex.
No
c.
(4 Points) A back edge which joins a black vertex to a gray vertex.
Yes
d.
(4 Points) A forward edge which joins a white vertex to a gray vertex.
No
e.
(4 Points) A cross edge which joins a gray vertex to a white vertex.
No
2.
(20 Points)
Trace Depth First Search (DFS) on the directed graph
G
below.
Process the vertices in
numerical order in line 5 of DFS, and line 3 of DFSVISIT.
(See the last page for DFS pseudocode.)
1
4
7
2
5
8
9
3
6
10
a.
(5 Points) Fill in the following table of discovery and finish times.
Draw the depthfirst forest.
Vertex
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '09
 AgoreBack
 Graph Theory, Vertex, Depthfirst search, 1 m

Click to edit the document details