Data Structures & AlgorithmsHardGATE CS · Product-company placement

DFS on the directed graph with adjacency lists A: CDG; B: –; C: –; D: BCF; E: –; F: CE; G: CE starts at A (scanning lists in the order shown, restarting from the alphabetically first unvisited vertex), with a clock that ticks on every discovery and every finish starting at 1. What are the discovery and finish times of E?

  1. A. 8/9
  2. B. 3/4
  3. C. 8/10
  4. D. 9/10

Correct answer: A. 8/9

Simulating with one tick per discovery and per finish gives d[E] = 8, f[E] = 9; the interval [d, f] of a vertex contains exactly the intervals of its DFS descendants.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic