Which of the following algorithm solves the all-pair shortest path problem?

2017

Which of the following algorithm solves the all-pair shortest path problem?

  1. A.

    Prim’s algorithm

  2. B.

    Dijikstra’s algorithm

  3. C.

    Bellman-Ford’s algorithm

  4. D.

    Floyd-Warshall’s algorithm

Attempted by 261 students.

Show answer & explanation

Correct answer: D

The All-Pair Shortest Path problem requires finding the shortest path between every pair of vertices in a graph. Floyd-Warshall’s algorithm is specifically designed for this task, dynamically computing shortest paths between all pairs of nodes. In contrast, Prim’s algorithm is used for Minimum Spanning Trees, while Dijkstra’s and Bellman-Ford algorithms are designed for Single-Source Shortest Path problems.

Explore the full course: Isro