Data Structures & AlgorithmsHardProduct-company placement

DFS on the directed graph with adjacency lists A: –; B: ACF; C: FG; D: E; E: BC; F: A; G: A 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 C?

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

Correct answer: D. 4/9

Simulating with one tick per discovery and per finish gives d[C] = 4, f[C] = 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