GATE Computer ScienceHardGATE CS (PYQ pattern)

A topological order of the DAG with edges A→B, A→C, B→D, C→D, C→E, D→F, E→F, E→G, G→F, H→C, H→G is produced by running DFS (roots in alphabetical order, each adjacency list in the order written above) and listing vertices in decreasing finishing time. Which vertex is fourth in this order?

  1. A. E
  2. B. B
  3. C. D
  4. D. G

Correct answer: A. E

The DFS finishes in the order F, D, B, G, E, C, A, H, so the decreasing-finish list is H, A, C, E, G, B, D, F. The fourth vertex is E.

More Algorithms questions

Exams that ask this topic