GATE DA 2024 | Question 51
Consider the directed acyclic graph (DAG) below:

Which of the following is/are valid vertex orderings that can be obtained from a topological sort of the DAG?
Explanation
Answer: (B), (D)
In a topological order every edge points forward, so each vertex comes after all of its predecessors. The edges are \(P \to Q\), \(R \to Q\), \(Q \to S\), \(Q \to V\), \(S \to U\) and \(V \to T\): P and R must precede Q, Q must precede S and V, S must precede U, and V must precede T.
- A and C fail: both place Q before R, which breaks the edge \(R \to Q\).
- B holds: after P, R, Q come V, S, U, T, so U follows S and T follows V.
- D holds: P, R, Q, S, V, T, U also respects every edge.
More than one order is valid because the chains \(S \to U\) and \(V \to T\) do not depend on each other.
Answer: B, D