Question
Consider the tree arcs of a BFS traversal from a source node in an unweighted, connected, undirected graph. The tree formed by the tree arcs is a data structure for computing
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.
- In an unweighted, connected, undirected graph , Breadth-First Search (BFS) explores vertices in increasing order of their hop distance from the start vertex .
- A vertex at distance from is discovered only after all reachable vertices at distance have been discovered.
- The tree edges of the BFS tree connect each vertex to the predecessor vertex from which was first visited.
- Consequently, the unique simple path from to any vertex along the tree edges in has minimum possible length (minimum number of edges) in .
- Therefore, the BFS tree serves as a data structure representing the shortest path from 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.