In an unweighted, undirected connected graph, the shortest path from a node to every other node is computed most efficiently, in terms of time complexity, by
View worked solution
Answer: D
For an unweighted, undirected connected graph , the shortest path from a source node to all other nodes is measured by the minimum number of edges. We can analyze the efficiency of the given algorithms for this task:
- Breadth-First Search (BFS): BFS explores the graph level-by-level starting from . The first time a node is visited during BFS, it is guaranteed to be reached via the shortest possible path. The time complexity of BFS is , which is optimal (linear time).
- Dijkstra's Algorithm: Designed for weighted graphs with non-negative edge weights. While it can be used for unweighted graphs (by treating all weights as ), its time complexity is (using a Fibonacci heap) or (using a binary heap), which is asymptotically slower than BFS.
- Depth-First Search (DFS): DFS explores as deep as possible along each branch before backtracking. It does not guarantee finding the shortest path in terms of the number of edges.
- Warshall's Algorithm: Used for finding the transitive closure of a graph (or Floyd-Warshall for all-pairs shortest paths), which runs in time and is highly inefficient for single-source shortest paths.
Therefore, BFS is the most efficient algorithm for this problem.
Free practice · Your answers on this page are not saved.
