GATE Computer ScienceHardGATE CSE · NIELIT

A DAG on vertices 0..5 has edges 0→2, 1→2, 1→3, 2→4, 3→4, 3→5, 4→5. How many distinct topological orderings does it have?

  1. A. 7
  2. B. 5
  3. C. 3
  4. D. 10

Correct answer: B. 5

Vertex 5 must come last (it follows 3 and 4 and everything reaches it); counting the valid orders of the other five vertices gives 5.

More Algorithms questions

Exams that ask this topic