Which of the following algorithms solves the all-pairs shortest path problem?

2018

Which of the following algorithms solves the all-pairs shortest path problem?

Answer: B. Floyd’s algorithmThe all-pairs shortest path problem is solved by Floyd’s algorithm (Floyd–Warshall algorithm) , which computes shortest paths between every pair of vertices…

  1. A.

    Dijkstra’s algorithm

  2. B.

    Floyd’s algorithm

  3. C.

    Prim’s algorithm

  4. D.

    Warshall’s algorithm

Attempted by 507 students.

Show answer & explanation

Correct answer: B

The all-pairs shortest path problem is solved by Floyd’s algorithm (Floyd–Warshall algorithm) , which computes shortest paths between every pair of vertices using dynamic programming. Dijkstra’s algorithm → single-source shortest path

Prim’s algorithm → minimum spanning tree

Warshall’s algorithm → transitive closure

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs

Loading lesson…