Skip to content
Official PYQ · 2007

GATE CS 2007 Q5 — Graph Traversals (BFS, DFS)

Explain with AI

Consider the DAG with V={1,2,3,4,5,6}V = \{1,2,3,4,5,6\} shown below.

Which of the following is not a topological ordering?

Choose one option
View worked solution

Answer: D

In the given Directed Acyclic Graph (DAG), the directed edges are:

  • 1→21 \to 2 and 1→31 \to 3
  • 2→42 \to 4 and 3→43 \to 4
  • 4→54 \to 5 and 4→64 \to 6

A topological ordering of a DAG is a linear ordering of its vertices such that for every directed edge u→vu \to v, vertex uu comes before vv in the ordering.

From the edge constraints:

  • Since there are directed edges 1→21 \to 2 and 1→31 \to 3, vertex 11 must appear before both 22 and 33.
  • Since there are directed edges 2→42 \to 4 and 3→43 \to 4, both 22 and 33 must appear before 44.

Looking at Option D: 3 2 4 1 6 5

Here, vertex 11 appears after 22, 33, and 44. This violates the dependency constraints 1→21 \to 2 and 1→31 \to 3. Therefore, this is not a valid topological ordering.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Graph Traversals (BFS, DFS) questions