Docsity

COMPLETED Classwork activity DFS and BFS, Schemes and Mind Maps of Computer science

Toggle sidebar
bg1
Classwork)DFS)and)BFS)
) ) Name: __________________________________
Name: __________________________________
Here is an unweighted graph of vertices and edges.
1. Perform a DFS from node d. When choosing which edges to
process first, do them in alphabetical order. So, node c would be
processed before node e. As you step through the algorithm for
each node, indicate its parent (predecessor) and the discover/finish times in the table. For example, d’s
parent is NULL and its discover time is 1.
2. Now, repeat the DFS from node f. Complete the table above in the same way as for question #1
3. Which nodes will not be discovered?
NODE
PARENT
DISCOVERY
d
null
1
NODE
PARENT
DISCOVERY
f
null
1
c
a
b
d
g
f
e
c
a
b
d
g
e
Shrey Patel
c
d
2
b
c
3
a
b
4
f
b
6
e
f
7
b
f
2
a
b
3
c
b
5
d
c
6
e
d
7
g
pf2

Partial preview of the text

Download COMPLETED Classwork activity DFS and BFS and more Schemes and Mind Maps Computer science in PDF only on Docsity!

Classwork DFS and BFS

Name: __________________________________

Name: __________________________________

Here is an unweighted graph of vertices and edges.

  1. Perform a DFS from node d. When choosing which edges to process first, do them in alphabetical order. So, node c would be processed before node e. As you step through the algorithm for each node, indicate its parent (predecessor) and the discover /finish times in the table. For example, d ’s parent is NULL and its discover time is 1.
  2. Now, repeat the DFS from node f. Complete the table above in the same way as for question #
  3. Which nodes will not be discovered?

NODE PARENT DISCOVERY

d null 1

NODE PARENT DISCOVERY

f null 1

c

a b

d g

f e

c

a b

d g

f e

  1. Perform a BFS starting with node d on the same graph:
  2. Show the order in which vertices are explored: d
  3. For each node, indicate its distance from d :

NODE DISTANCE

a

b

c

d 0

e

f

g

c

a b

d g

f e