Which algorithm is used to find the shortest path between all pairs of…
2026
Which algorithm is used to find the shortest path between all pairs of vertices in a weighted graph ?
- A.
Dijkstra's algorithm
- B.
Bellman-Ford algorithm
- C.
Floyd-Warshall algorithm
- D.
Prim's algorithm
Attempted by 46 students.
Show answer & explanation
Correct answer: C
The Floyd-Warshall algorithm is used to find shortest paths between all pairs of vertices in a weighted graph. It uses dynamic programming and gradually allows each vertex as an intermediate vertex. Dijkstra and Bellman-Ford solve single-source shortest-path problems, while Prim's algorithm finds a minimum spanning tree.