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 ?

  1. A.

    Dijkstra's algorithm

  2. B.

    Bellman-Ford algorithm

  3. C.

    Floyd-Warshall algorithm

  4. 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.

Explore the full course: Tpsc Assistant Technical Officer