Example 1 (DFS)
The graph is the same as in Example 1 of Dijkstras algorithm, but without the weights.
Initialization: n = 10. Choose vertex A and assign label (1, ). k = 1.
Step 1: There are adjacent unlabelled vertices, so go to Step 2.
Step 2: B is an
1
Graph for in-class Depth-First Search Example
(This is called Example 2 on the web site)
Use the Depth-First Search algorithm to nd a spanning tree in the graph shown here:
r
rr
$
rr
$
$
rr
r
rr
rr
rr
r
d
d rr
d
rr
d
d
rr
d
d
d
d
d
d
Depth-First Search Algorithm (Variant)
Consider any graph G(V , E ).
Initialization: Let n = |V|.
Dene: In any vertex label (l, p), l is the number assigned to the vertex and p is the predecessor
vertexs assigned number.
(Optional: Let Labels = (1, 0, .,
Chapter 9
Chapter 10.1
Let u and v be distinct vertices in a graph G. Prove that there is a walk from u to v iff there is a
path from u to v.
Chapter 10.2
THE UNIVERSITY OF WESTERN ONTARIO
FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
SE 2251A Discrete Structures for Software Engineers
Course Outline 2010 - 2011
Instructor:
Dr. Vicki Olds, Dept. of Mathematics, MC 103g, Ext. 86520
November 19, 2010
Page 1
Software Engineering 2251A
Second Midterm Exam
10
marks
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
The function f : N N dened by f
October 22, 2010
Page 1
Software Engineering 251a
First Midterm Exam
10
marks
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
If 22 = 5 then 32 = 9.
True
False
Chapter 3.2
22) Suppose f : A B and g : B C are functions
a) If g f is one-to-one and f is onto, show that g is one-to-one.
b) If g f is onto and g is one-to-one, show that f is onto.
23)
a) Prove that the composition of one-to-one functions is a one-to-o
Software Engineering 2251A
Final Exam
4
marks
1.
(a) Use the Depth-First Search algorithm, starting from the vertex labelled 1
to nd a spanning tree in the graph shown here. Clearly indicate on the graph
the edges which are used in the spanning tree. You
Software Engineering 2251A
Final Exam
6
marks
1.
December 8, 2008
Page 1
(a) What is the maximum possible degree of any vertex in a connected graph with
n vertices? (Justify your answer.)
(b) What is the minimum possible degree of any vertex in a connecte
Software Engineering 2251A
Final Exam
6
marks
1.
December 8, 2008
Page 1
(a) What is the maximum possible degree of any vertex in a connected graph with
n vertices? (Justify your answer.)
Solution: Let v be any vertex in the graph. Since a graph contains
Software Engineering 251a
Final Exam
December 13, 2007
Page 1
8
1. Consider the graph G(V , E ) shown here:
marks
A
B
y
e
e
e
e
C
y
e
e
e
e
y
e
e
e
e
e
e
e
yE
ey
eyH
D ey
G y
e
e
e
Fe
e
e
e
e
e
e
e
e
e
e
e
ey
ey
ey
I
J
K
(a) What property does G pos
December 13, 2007
Page 1
Software Engineering 251a
Final Exam
1. [8 marks ] Consider the graph G(V , E ) shown here:
A
B
C
u
e
e
u
u
e
e
e
e
e
eu
e
e G u
uE e u
eH
Du
e
e
e
F
e
e
e
e
e
eu
eu
eu
e
I
J
K
(a) What property does G possess that ensures G is
Software Engineering 2251a
Second Midterm Exam
10
marks
November 17, 2009
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
If f = cfw_ (a, a + 1) | a Z, a
Software Engineering 2251a
Second Midterm Exam
10
marks
November 17, 2009
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
If f = cfw_ (a, a + 1) | a Z, a
Software Engineering 2251a
Second Midterm Exam
10
marks
November 11, 2008
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
If f : N N is dened by f = cfw_
Software Engineering 2251a
Second Midterm Exam
10
marks
November 11, 2008
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
If f : N N is dened by f = cfw_
Software Engineering 251a
Second Midterm Exam
10
marks
November 12, 2007
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
If the function f : A B is one-t
Software Engineering 251a
Second Midterm Exam
November 12, 2007
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
If the function f : A B is one-to-one, th
Software Engineering 2251A
First Midterm Exam
10
marks
October 20, 2009
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
The converse of If I can then I w
Software Engineering 2251A
First Midterm Exam
10
marks
October 20, 2009
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
The converse of If I can then I w
Software Engineering 2251a
First Midterm Exam
10
marks
October 9, 2008
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
The contrapositive of If I can the
Software Engineering 2251a
First Midterm Exam
October 9, 2008
Page 1
1. [ 10 marks ] For each part of this question, determine whether the statement is True or False and circle
the correct response. Each is worth 1 mark.
(a)
The contrapositive of If I can
Software Engineering 251a
First Midterm Exam
10
marks
October 15, 2007
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
The negation of I can and I will i
Software Engineering 251a
First Midterm Exam
October 15, 2007
Page 1
1. For each part of this question, determine whether the statement is True or False and circle the correct
response. Each is worth 1 mark.
(a)
The negation of I can and I will is I cant
1
Challenge #40
(a) Given a graph G(V , E ), what algorithm(s) that were already (before DepthFirst Search) learnt could be used to test whether G is connected?
(b) What makes the DFS algorithm more ecient?
Challenge #40 - Solution
(a) Either of the algorithms we have already learned for weighted graphs
the Shortest Path or Minimum Spanning Tree algorithms could be used
to determine whether a graph is connected. If its not a weighted graph,
we could just as
1
Challenge #39
Consider any connected weighted graph G(V , E ). Consider any u V .
Let G (V , E ) be the subgraph of G dened by
E is the set of all edges used in shortest paths from u to each other
vertex in V .
Prove that G is a spanning tree of G.