Skip to content
Official PYQ · 2025

GATE CS 2025 Set 2 Q19 — Graph Traversals (BFS, DFS)

Explain with AI

​​​​Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph GG is/are TRUE?

Select all correct options
View worked solution

Answer: B;C;D

Let us analyze each statement for an undirected simple graph GG:

  • Statement A (False): DFS does not guarantee shortest paths. For example, in a triangle graph with vertices A,B,CA, B, C, a DFS starting at AA might yield the path A→B→CA \to B \to C. The distance to CC in this DFS tree is 22, whereas the actual shortest path distance is 11.
  • Statement B (True): In a DFS traversal of an undirected graph, there are no cross edges. Every non-tree edge must connect an ancestor to a descendant in the DFS tree, which classifies it as a back edge (or forward/back edge).
  • Statement C (True): In a BFS tree of an undirected graph, any edge (u,v)(u, v) in GG can only connect vertices at the same level or at adjacent levels. Thus, the distances from the source ss satisfy ∣d(s,u)−d(s,v)∣≤1|d(s, u) - d(s, v)| \le 1.
  • Statement D (True): Both BFS and DFS can traverse all reachable vertices from a starting node. By repeatedly launching either traversal from any unvisited vertex, we can easily identify and count all connected components of GG.

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

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