Question

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
Official answer and solution
Official answer
B
From
Official GATE 2014 answer key

Solution

Recall the structural property of Breadth-First Search (BFS) trees in unweighted graphs.

  1. In an unweighted, connected, undirected graph GG, Breadth-First Search (BFS) explores vertices in increasing order of their hop distance from the start vertex WW.
  2. A vertex at distance dd from WW is discovered only after all reachable vertices at distance <d< d have been discovered.
  3. The tree edges of the BFS tree TT connect each vertex vv to the predecessor vertex from which vv was first visited.
  4. Consequently, the unique simple path from WW to any vertex vv along the tree edges in TT has minimum possible length (minimum number of edges) in GG.
  5. Therefore, the BFS tree TT serves as a data structure representing the shortest path from WW to every vertex in the graph (option B).
Final answer

B

Common trap

Thinking BFS from a single source computes all-pairs shortest paths (which would require BFS from all vertices, O(V(V+E))).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 2
Question
24 of 65, printed as CS Q.14
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.