GATE Computer ScienceModerateGATE CSE · UGC NET

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

  1. A. 6
  2. B. 4
  3. C. 3
  4. D. 8

Correct answer: B. 4

Vertices 0 and 1 precede 2 in either order (2 ways), then 3 and 4 in either order (2 ways), then 5: 2 × 2 = 4.

More Algorithms questions

Exams that ask this topic