UGC-NET Dec 2014 · Shortest Path Algorithms

MCQ · 2 marks · Problem PROG-GRPH-0008

Dijkstra algorithm, which solves the single-source shortest--paths problem, is a , and the Floyd-Warshall algorithm, which finds shortest paths between all pairs of vertices, is a .
  1. A
    Greedy algorithm, Divide-conquer algorithm
  2. B
    Divide-conquer algorithm, Greedy algorithm
  3. C
    Greedy algorithm, Dynamic programming algorithm
  4. D
    Dynamic programming algorithm, Greedy algorithm

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

Show the worked solutionDijkstra's algorithm repeatedly fixes the vertex with the smallest tentative distance and never revisits that choice — a greedy algorithm.Floyd-Warshall builds \(d^{(k)}_{ij}=\min\big(d^{(k-1)}_{ij},\ d^{(k-1)}_{ik}+d^{(k-1)}_{kj}\big)\), reusing the answers for intermediate vertices \(1..k-1\) — dynamic programming.(A), (B) Neither algorithm is divide and conquer — incorrect.(D) Swaps the two paradigms — incorrect.Answer: C

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