Data Structures & AlgorithmsHardGATE CS · Product-company placement

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

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

Correct answer: C. 6

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): 6 orderings in total.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic