GATE CS 2025 Set 2 | Question 29

Algorithms › Graph Algorithms · MSQ · 1 mark · Answer: B, C, D

  1. Question 29Algorithmsmsq1 mark
    Which of the following statements regarding BFS and DFS on an undirected simple graph is/are TRUE?
    • A.
      A DFS tree of is a Shortest Path tree of .
    • B.
      Every non-tree edge of with respect to a DFS tree is a forward/back edge.
      ✓
    • C.
      If is a non-tree edge of with respect to a BFS tree, then the distances from the source to and in the BFS tree are within of each other.
      ✓
    • D.
      Both BFS and DFS can be used to find the connected components of .
      ✓

    Answer: B, C, D

    Solution

    Answer: (B), (C) and (D) - (A) A DFS tree is not generally a shortest-path tree. FALSE. - (B) On an undirected graph, DFS produces only tree edges and back edges (no forward/cross edges), so every non-tree edge is a back edge — consistent with "forward/back edge". TRUE. - (C) For BFS on an undirected graph, any non-tree edge connects vertices whose BFS levels differ by at most 1. TRUE. - (D) Running BFS/DFS from each unvisited vertex identifies all connected components. TRUE.

More GATE PYQ on Graph Algorithms

All GATE CS Algorithms PYQ →

Attempt GATE CS 2025 Set 2 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →