GateAI
Graph Traversals

GATE CSE 2025 Set 2 · Q29

MSQ1 markMedium

Time

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 that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: B) Every non-tree edge of G with respect to a DFS tree is a forward/back edge.; C) If (u, v) is a non-tree edge of G with respect to a BFS tree, then the distances from the source vertex s to u and v in the BFS tree are within ± 1 of each other.; D) Both BFS and DFS can be used to find the connected components of G.

Graph Traversals

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

  • Statement (A) is FALSE: A DFS tree does not guarantee shortest paths from the source. In an unweighted undirected graph, a BFS tree produces the shortest path tree, whereas DFS traverses deeply along one branch and may find significantly longer paths.

  • Statement (B) is TRUE: In the DFS traversal of an undirected graph, every edge of GG is either a tree edge or a back edge (an edge connecting a vertex to its ancestor/descendant in the DFS tree). There are no cross edges between unrelated subtrees.

  • Statement (C) is TRUE: In an undirected BFS tree rooted at ss, any non-tree edge (u,v)(u, v) can only connect vertices at the same level or at adjacent levels. Therefore, ∣d(s,u)−d(s,v)∣≤1|d(s, u) - d(s, v)| \le 1, meaning the distances are within ±1\pm 1 of each other.

  • Statement (D) is TRUE: Both BFS and DFS can traverse all reachable vertices from a given starting vertex. By repeatedly initiating BFS or DFS from an unvisited vertex until all vertices are visited, one can identify all connected components of GG.

Hence, statements B, C, and D are correct.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Graph Traversals previous year question is Q29 of the GATE CSE 2025 Set 2 paper. Find more GATE CSE PYQs on Graph Traversals in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Graph Traversals in GATE CSE

Graph Traversals has 16 GATE CSE PYQs across 12 papers from 2014 to 2026. This is the only 1-mark MSQ among them, and GATE CSE 2025 Set 2 has 2.

How GATE tests Graph Traversals

More from GATE CSE 2025 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2025 Set 2 · Q29 · MSQ

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

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.