Skip to content
Official PYQ · 2014

GATE CS 2014 Set 2 Q14 — Graph Traversals (BFS, DFS)

Explain with AI

Consider the tree arcs of a BFS traversal from a source node WW in an unweighted, connected, undirected graph. The tree TT formed by the tree arcs is a data structure for computing

Choose one option
View worked solution

Answer: B

Breadth-First Search (BFS) on an unweighted, connected, undirected graph explores vertices level by level, starting from a source vertex WW.

During BFS, when we traverse an edge to discover an unvisited vertex, that edge becomes a tree arc. The collection of these tree arcs forms a BFS tree TT rooted at WW.

  • Shortest Path Property: For any vertex vv in the graph, the unique path from the root WW to vv in the BFS tree TT has the minimum possible number of edges. Thus, it represents the shortest path from WW to vv in the unweighted graph.
  • Since the graph is connected, BFS visits every vertex. Therefore, the tree TT contains the shortest path from WW to every vertex in the graph.

Analyzing the Options:

  • Option A: Incorrect. BFS from a single source WW only computes shortest paths originating from WW, not between every arbitrary pair of vertices.
  • Option B: Correct. The BFS tree TT provides the shortest path from the source WW to all vertices in the graph.
  • Option C: Incorrect. The shortest paths are computed for all vertices in the tree, not just the leaf nodes.
  • Option D: Incorrect. BFS is not used for finding longest paths.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Graph Traversals (BFS, DFS) questions