Data Structures & AlgorithmsHardProduct-company placement

DFS on the directed graph with adjacency lists A: CDE; B: FG; C: –; D: G; E: FG; F: AG; G: – 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/11
  2. B. 2/7
  3. C. 8/10
  4. D. 9/12

Correct answer: A. 8/11

Simulating with one tick per discovery and per finish gives d[E] = 8, f[E] = 11; 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