Data Structure (2130702)

BE | Semester-3   Summer-2016 | 06/09/2016

Q4) (a)

Explain Depth First Search in graphs with an example.

Depth First Search (DFS)
  • It is like preorder traversal of tree.
  • Traversal can start from any vertex vi.
Vi is visited and then all vertices adjacent to vi are traversed recursively using DFS
DFS (G, 1) is given by
1) Visit (1)
2) DFS (G, 2) DFS (G, 3) DFS (G, 4) DFS (G, 5)

 

1, 2, 6, 3, 8, 7, 4, 5