Skip to content
Official PYQ · 2007

GATE CS 2007 Q41 — Shortest Paths (Dijkstra, Bellman-Ford)

Explain with AI

In an unweighted, undirected connected graph, the shortest path from a node SS to every other node is computed most efficiently, in terms of time complexity, by

Choose one option
View worked solution

Answer: D

For an unweighted, undirected connected graph G=(V,E)G = (V, E), the shortest path from a source node SS 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 SS. 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 O(V+E)\mathcal{O}(V + E), 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 11), its time complexity is O(E+Vlog⁡V)\mathcal{O}(E + V \log V) (using a Fibonacci heap) or O((V+E)log⁡V)\mathcal{O}((V + E) \log V) (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 O(V3)\mathcal{O}(V^3) 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.

Published
Report a correction
Keep exploringMore Shortest Paths (Dijkstra, Bellman-Ford) questions