UGC-NET Jun 2015 · Shortest Path Algorithms

MCQ · 2 marks · Problem PROG-GRPH-0009

An all-pairs shortest-paths problem is efficiently solved using:
  1. A
    Dijkstra's algorithm
  2. B
    Bellman-Ford algorithm
  3. C
    Kruskal algorithm
  4. D
    Floyd-Warshall algorithm

Solve it on GATE DA practice →More Graph Theory & Algorithms problems

Show the worked solutionFloyd-Warshall computes shortest paths between every pair of vertices in one \(\Theta(V^3)\) dynamic program, and it allows negative edge weights (no negative cycles).(A) Dijkstra is single-source; running it from every vertex works only for non-negative weights.(B) Bellman-Ford is single-source; running it from every vertex costs \(O(V^2E)\).(C) Kruskal finds a minimum spanning tree, not shortest paths — incorrect.Answer: D

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com