GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A DAG on vertices 1–8 has edges 1→2, 1→3, 2→4, 3→4, 4→5, 4→6, 5→7, 6→7, 3→8, 8→7. How many different topological orderings does it have?

  1. A. 12
  2. B. 16
  3. C. 24
  4. D. 18

Correct answer: D. 18

Vertex 1 must come first and 7 last; 4 needs both 2 and 3, 5 and 6 need 4, and 8 only needs 3. Counting linear extensions by dynamic programming over subsets of already-placed vertices gives 18 (checked by exhaustive count).

More Algorithms questions

Exams that ask this topic