Skip to content
Related Articles
Open in App
Not now

Related Articles

Algorithms | Graph Shortest Paths | Question 4

Improve Article
Save Article
Like Article
  • Last Updated : 08 Sep, 2021
Improve Article
Save Article
Like Article

In an unweighted, undirected connected graph, the shortest path from a node S to every other node is computed most efficiently, in terms of time complexity by
(A) Dijkstra’s algorithm starting from S.
(B) Warshall’s algorithm
(C) Performing a DFS starting from S.
(D) Performing a BFS starting from S.


Answer: (D)

Explanation:

 * Time Complexity of the Dijkstra’s algorithm is O(|V|^2 + E)  
 * Time Complexity of the Warshall’s algorithm is O(|V|^3)
 * DFS cannot be used for finding shortest paths
 * BFS can be used for unweighted graphs. Time Complexity for BFS is O(|E| + |V|)


Quiz of this Question

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!