Data Structures & AlgorithmsHardGATE CS · Product-company placement

How many topological orderings does the DAG on vertices A–F with edges A→C, B→D, D→C, E→C, F→A, F→C have?

  1. A. 30
  2. B. 29
  3. C. 32
  4. D. 60

Correct answer: A. 30

Count by placing vertices one at a time, each time choosing any vertex whose predecessors are all placed (or DP over subsets of placed vertices): 30 orderings in total.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic