GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A DAG on vertices 1..7 has edges 1->2, 1->3, 2->4, 3->4, 3->5, 4->6, 5->6, 7->5. How many distinct topological orderings does it have?

  1. A. 14
  2. B. 29
  3. C. 42
  4. D. 21

Correct answer: D. 21

Count linear extensions: brute force over the 7! orderings that respect every edge gives 21.

More Programming and Data Structures (GATE) questions

Exams that ask this topic