Consider the following graph, Among the following sequences: (I) a b e g h f…

2003

Consider the following graph, 






Among the following sequences: 

(I) a b e g h f 
(II) a b f e h g
(III) a b f h g e 
(IV) a f g h b e  


Which are depth first traversals of the above graph? 

  1. A.

    I, II and IV only 

  2. B.

    I and IV only 

  3. C.

    II, III and IV only 

  4. D.

    I, III and IV only 

Attempted by 57 students.

Show answer & explanation

Correct answer: D

To determine valid depth-first traversals, we must check if each sequence follows a valid DFS path—moving from one vertex to an adjacent unvisited vertex, and backtracking only when necessary. The graph has vertices a, b, e, f, g, h with edges connecting them.

Sequence I (a b e g h f): Starts at a, moves to b, then to e. From e, it can go to g (via edge e-g), then h (g-h), and finally f. This is a valid DFS path.

Sequence II (a b f e h g): Starts a→b→f. However, there is no edge between f and e in the graph, so moving from f to e violates DFS connectivity. This sequence is invalid.

Sequence III (a b f h g e): Starts a→b→f, then to h (via f-h), then to g (h-g), and finally to e. This path is valid as all edges exist.

Sequence IV (a f g h b e): Starts a→f→g→h. After reaching h, it backtracks to b (via h-b), then to e. This path is valid as all edges are present.

Thus, sequences I, III, and IV are valid depth-first traversals. Sequence II is invalid due to the missing edge f-e.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir