Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph is/are TRUE?
View worked solution
Answer: B;C;D
Let us analyze each statement for an undirected simple graph :
- Statement A (False): DFS does not guarantee shortest paths. For example, in a triangle graph with vertices , a DFS starting at might yield the path . The distance to in this DFS tree is , whereas the actual shortest path distance is .
- 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 in can only connect vertices at the same level or at adjacent levels. Thus, the distances from the source satisfy .
- 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 .
Free practice · Your answers on this page are not saved.
