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

2025

Consider the following graph,

image.png

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 68 students.

Show answer & explanation

Correct answer: D

Depth First Search (DFS) explores as far as possible along each branch before backtracking. For the given graph, valid DFS sequences must respect parent-child relationships and visit all reachable nodes without skipping unvisited neighbors prematurely. Sequence I (a b e g h f) follows a valid path where each node is visited before its siblings. Sequence II (a b f e h g) incorrectly visits f before exploring all children of b, violating DFS rules. Sequence III (a b f h g e) maintains proper traversal order by completing branches before backtracking. Sequence IV (a f g h b e) starts with a different branch but remains valid if the graph structure allows it. Therefore, sequences I, III, and IV are correct DFS traversals.

Explore the full course: Niacl Ao It Specialist