Consider the following directed graph: The number of different topological orderings of the vertices of the graph is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2016 Set 1 · Q11
Time

Your answerNumerical answer
Solution
Official answer: 6 (±0)
Graph TraversalsIn a topological ordering of a Directed Acyclic Graph (DAG), for every directed edge , vertex must appear before vertex .
Vertex has in-degree , so it must always appear first (at position 1).
Vertex has out-degree , so it must always appear last (at position 6).
The remaining vertices are along two independent paths:
Path 1: (meaning must appear before )
Path 2: (meaning must appear before )
The 4 intermediate positions (positions 2, 3, 4, 5) must be filled by the set of vertices .
The total number of valid topological orderings corresponds to the number of ways to interleave the sequences and into 4 positions:
The 6 possible topological orderings are:
Hence, the correct answer is 6.
Try the question first, then check your work.
Examiner trap
Vertex must be first and vertex must be last. Count the number of ways to interleave the two independent chains and .
This Graph Traversals previous year question is Q11 of the GATE CSE 2016 Set 1 paper. Find more GATE CSE PYQs on Graph Traversals in Algorithms, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Graph Traversals PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Graph Traversals has 16 GATE CSE PYQs across 12 papers from 2014 to 2026. 2 of them are 1-mark NAT questions like this one, and it is the only one in GATE CSE 2016 Set 1.
How GATE tests Graph TraversalsIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.