Computer Sciences > GATE 2025 SET-2 > Graph Traversal
Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph G is/are TRUE?
A
A DFS tree of G is a Shortest Path tree of G.
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.

Correct : d

The correct answer is Option D — Both BFS and DFS can be used to find the connected components of G.
Let''s evaluate each option for an undirected simple graph G.
Option A - A DFS tree is a shortest path tree: False. DFS dives deep without regard for edge count, so DFS tree paths are not necessarily shortest. It''s BFS that guarantees shortest paths in unweighted graphs.
Option B - Non-tree edges in DFS are forward/back edges: False as stated. In an undirected graph, all non-tree edges in a DFS are back edges only- there are no forward edges or cross edges. The option mentions "forward/back" which makes it incorrect since forward edges don''t appear in undirected DFS.
Option C - Non-tree BFS edge (u,v): distances within ±1: This is actually true for undirected graphs - if (u,v) is a non-tree edge in a BFS tree, then |d(u) − d(v)| ≤ 1. However, the official GATE key marks only D as correct, possibly because the question intends a stricter interpretation or the phrasing implies something broader.
Option D - Both BFS and DFS find connected components: True. Running BFS or DFS from each unvisited vertex and grouping all visited vertices together gives the connected components. Both algorithms explore all reachable vertices from a source, making them equally capable of connected component detection.

Similar Questions

A palindrome is a word that reads the same forwards and backwards. In a game of words, a player has the following two plates painted with letters. From...
#1 MCQ
Which number does not belong in the series below? 2, 5, 10, 17, 26, 37, 50, 64
#4 MCQ
Choose the word that is opposite in meaning to the word “coherent”.
#5 MCQ

Related Topics

BFS DFS GATE 2025 GATE CS 2025 Set-2 Q29 BFS DFS undirected graph DFS tree shortest path BFS non-tree edge distance connected components BFS DFS graph traversal GATE DFS back edge undirected BFS shortest path tree algorithms GATE 2025 graph theory GATE CS

Unique Visitor Count

Total Unique Visitors

Loading......