GATE Computer ScienceVery hardGATE CSE · UGC NET

A directed graph on vertices 1–8 has adjacency lists 1:[2,5]; 2:[3,6]; 3:[4,1]; 4:[2,7]; 5:[6,4]; 6:[7]; 7:[5,8]; 8:[3,6]. DFS starts at vertex 1 and always scans adjacency lists left to right. How many (back edges, forward edges, cross edges) does it find, as a triple?

  1. A. (5, 2, 1)
  2. B. (6, 2, 0)
  3. C. (5, 3, 0)
  4. D. (4, 2, 2)

Correct answer: A. (5, 2, 1)

DFS gives 7 tree edges (all 8 vertices reached from 1); classifying the other edges by discovery/finish times gives 5 back, 2 forward and 1 cross.

More Programming and Data Structures (GATE) questions

Exams that ask this topic