IAE Academy

GATE 2026 DA Q.40: solution and answer

GATE 2026 · DAQ.40 · 2 marks · MCQ

Consider a directed graph , where is the finite set of vertices and is the set of directed edges between the vertices. may contain cycles but there is no self-loop. Further, may not be strongly connected.

Let be the graph obtained by reversing the directions of all the edges in without changing the set of vertices.

Assume that Breadth First Search (BFS) or Depth First Search (DFS) from any given vertex of a graph visits only the reachable vertices from in that graph.

Which of the following statements must always be true, regardless of the structure of ?

  1. (A)

    If is a reachable vertex in the BFS of from , then is also a reachable vertex in the DFS of from .

  2. (B)

    In , the BFS traversal from will visit exactly the same set of vertices as the DFS from in .

  3. (C)

    The order of vertices visited in the BFS of from is the reverse of the order of vertices visited in the DFS of from .

  4. (D)

    If is a reachable vertex in the DFS of from , then is also a reachable vertex in the BFS of from .

See the question in the paper

Answer and solution

ANSWER

The answer is (D): reachability in from to is exactly reachability in from to .

Official answer: DSource: Official answer key, GATE 2026 DA (IIT Guwahati)

  1. BFS and DFS from a vertex both visit exactly the vertices reachable from it, so each statement reduces to a claim about paths. Reversing every edge turns a path in into a path in , and conversely.

  2. (A) reached by BFS of from means there is a path in , which is a path in . DFS of from reaches only if there is a path in . Counterexample: has the single edge . Then has the edge , so BFS of from reaches , but DFS of from visits only . False.

  3. (B) BFS in from visits the vertices that can reach in , while DFS in from visits the vertices reachable from . Take with only the edge . DFS in visits , but has only the edge , so BFS in from visits . The sets differ. False.

  4. (C) Take with edges and . In the edges are and , so BFS from visits only , while DFS of from visits . The orders are not reverses of each other. False.

  5. (D) If DFS of from reaches , there is a path in . Reversing every edge gives a path in . BFS of from visits every vertex reachable from , so it visits . This uses only the path correspondence, so it holds for every , with or without cycles and whether or not is strongly connected. True.

KEY IDEA

Reversing all edges reverses every path, so in if and only if in . BFS and DFS both visit exactly the reachable set, so only statements phrased through this path reversal always hold.

WATCH OUT FOR

Treating reachability from in as the same as reachability from in (options A and B), or assuming BFS and DFS orders are related by reversal (option C). Only the start and end of the path swap, not the starting vertex.

From the GATE 2026 DA paper. Every question of this paper · Download the full paper · All 28 Graph algorithms questions, with notes

More Graph algorithms questions