This preview shows pages 1–6. Sign up to view the full content.
Discussion #34
Chapter 7, Pages 4368
1/13
Discussion #34
Properties and Applications of
DepthFirst Search Trees and Forests
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document Discussion #34
Chapter 7, Pages 4368
2/13
Topics
•
Depthfirst search trees and forests
•
Tree edges; forward, backward, and cross edges
•
Post order numbers
•
Applications
–
Cycles
–
Topological sorting
–
Reachability
–
Connected components
•
Reading
assignment,
pages 436 to 438, Exercises
13.
Discussion #34
Chapter 7, Pages 4368
3/13
DFS Trees and Forests
3
2
5
4
1
6
1
3
5
2
4
6
1
Convention:
increasing order
5
2
4
3
DFS Tree
DFS Trees
Forest
Note: O(
m
) to create
(check each edge once)
6
Convention: Roots in
decreasing order; other
nodes in increasing order
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document Discussion #34
Chapter 7, Pages 4368
4/13
Edge Classification
3
2
5
4
1
6
1
3
5
2
4
6
forward
backward
backward
cross
1
5
2
4
3
backward
cross
cross
cross
Add all edges
but make them dashed if a marked node is
encountered.
6
backward
cross
cross
Tree edge
if
y
is a child of
x
in DFS forest.
Forward edge
if
y
is a descendent of
x
, but not a child.
Backward edge
if
y
is an ancestor of
x
or if
x
=
y
.
Cross edge
if
y
is not
x
and is neither a descendent nor
an ancestor of
x
.
cross
Discussion #34
Chapter 7, Pages 4368
5/13
Observations about Edge Classification
•
Requires O(
m
) to create
each edge considered
only once
•
Only go between trees in a forest with cross edges
•
If we go left to right in building the DFS tree, then
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.
This note was uploaded on 03/02/2012 for the course C S 236 taught by Professor Michaelgoodrich during the Winter '12 term at BYU.
 Winter '12
 MichaelGoodrich

Click to edit the document details