GATE Computer ScienceVery hardGATE CSE

A DFS is run on a directed graph with adjacency lists 0:[1,4], 1:[2,5], 2:[0,3], 3:[1], 4:[5,6], 5:[3], 6:[4,5], 7:[3,6]. Vertices are tried in increasing order, restarting at the smallest unvisited vertex. How many edges are classified as cross edges, and how many as back edges?

  1. A. 6 cross, 2 back
  2. B. 5 cross, 4 back
  3. C. 5 cross, 3 back
  4. D. 4 cross, 4 back

Correct answer: C. 5 cross, 3 back

DFS tree edges: 6; classifying the rest by colour/discovery times gives 3 back, 0 forward and 5 cross edges.

More Algorithms questions

Exams that ask this topic