Data Structures & AlgorithmsVery hardGATE CS · Advanced

A directed acyclic graph has the vertices A–G and the arcs D→F, D→C, D→B, G→C, G→A, C→A, C→E, C→B. How many different topological orderings does it have?

  1. A. 560
  2. B. 74
  3. C. 66
  4. D. 60

Correct answer: C. 66

Count linear extensions by dynamic programming over subsets: the number of orderings ending with each available vertex is added up; the answer is 66.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic