Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph \(G\) is/are TRUE?
Answer
(B), (C), (D)
Explanation
- (A) False. In a triangle on \(s, a, b\), DFS from \(s\) may go \(s \to a \to b\), placing \(b\) at depth 2 although the edge \(sb\) puts it at distance 1.
- (B) True. If \(u\) is discovered before its neighbour \(v\), then \(v\) is discovered before \(u\) finishes, so \(v\) becomes a descendant of \(u\). Every non-tree edge therefore joins a vertex to one of its ancestors; undirected DFS has no cross edges.
- (C) True. BFS depths are shortest distances from \(s\), and an edge \((u, v)\) gives \(d(v) \le d(u) + 1\) and \(d(u) \le d(v) + 1\).
- (D) True. Restarting the search (BFS or DFS) from each unvisited vertex visits exactly one connected component per start.
Answer: B, C, D