V1
Graph f
V8
V7
V5
V6
V9
V20
V19
V15
V16
V18
V17
V12
V14
V13
V4
V2
V10
V3
Green arrow points to v2, the
second vertex. Red arrow
points to v11, the eleventh
vertex (there are twenty
vertices)
The length of any edge is 1 for simplicity.
(a) Starting from v2, with the goal to find v11 using DFS. Complete Table 1.
DFS
? nodes = 20
nodes
#
Node
edge
length dis
#
1 V2
6
2 V1
V2V1
1
1
7
3 V5
V1V5
1
2
8
4
9
5
10
(b) BFS. Starting from v2, with the goal to find v11 using BFS. Complete BFS.
BFS
? nodes = 20
nodes
#
Node
edge
length
dis
#
1
6
2
7
3
8
4
9
5
10