Skip to content
Official PYQ · 2018

GATE CS 2018 Q30 — Graph Traversals (BFS, DFS)

Explain with AI

Let GG be a simple undirected graph. Let TDT_D be a depth first search tree of GG. Let TBT_B be a breadth first search tree of GG. Consider the following statements.

  1. No edge of GG is a cross edge with respect to TDT_D. (A cross edge in GG is between two nodes neither of which is an ancestor of the other in TDT_D).
  2. For every edge (u,v)(u, v) of GG, if uu is at depth ii and vv is at depth jj in TBT_B, then ∣i−j∣=1\mid i-j \mid =1.

Which of the statements above must necessarily be true?

Choose one option
View worked solution

Answer: A

We analyze the two statements for a simple undirected graph GG:

Statement I: In a Depth First Search (DFS) of an undirected graph, every edge of GG is classified as either a tree edge or a back edge. If there is an edge (u,v)(u, v) in GG, the vertex visited first (say uu) must complete its exploration only after all its reachable descendants (including vv) are explored. Thus, one vertex must be an ancestor of the other, meaning there are no cross edges. Hence, Statement I is true.

Statement II: In a Breadth First Search (BFS) tree TBT_B, the depth difference between two adjacent vertices uu and vv in GG can be at most 11, i.e., ∣i−j∣≤1|i - j| \le 1. It is possible that ∣i−j∣=0|i - j| = 0 (i.e., they are at the same depth).
For example, consider a triangle graph K3K_3 with vertices {A,B,C}\{A, B, C\}. If we start BFS from AA (depth 00), both BB and CC will be at depth 11. The edge (B,C)(B, C) connects two vertices at the same depth, so ∣1−1∣=0≠1|1 - 1| = 0 \neq 1. Hence, Statement II is false.

Thus, only Statement I is necessarily true.

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

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