UGC-NET Dec 2015 · Shortest Path Algorithms

MCQ · 2 marks · Problem PROG-GRPH-0006

The Floyd-Warshall algorithm utilizes to solve the all-pairs shortest paths problem on a directed graph in time.
  1. A
    Greedy algorithm, \(\Theta(V^3)\)
  2. B
    Greedy algorithm, \(\Theta(V^2 \lg n)\)
  3. C
    Dynamic programming, \(\Theta(V^3)\)
  4. D
    Dynamic programming, \(\Theta(V^2 \lg n)\)

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

Show the worked solution\[\boxed{d^{(k)}_{ij}=\min\big(d^{(k-1)}_{ij},\ d^{(k-1)}_{ik}+d^{(k-1)}_{kj}\big)}\]Each table \(d^{(k)}\) (paths whose intermediate vertices are among the first \(k\)) is built from the stored table \(d^{(k-1)}\): dynamic programming, not a greedy choice.Three nested loops over \(k, i, j\) give \(\Theta(V^{3})\) time.The key imported with this question gave A (greedy), which is wrong.Answer: C

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