The GATE Grind

GATE 2016 CS (CS2) – Question 24

Algorithms · Dynamic Programming · 1 mark · Multiple choice

Which paradigm underlies Floyd–Warshall all-pairs shortest paths?

  1. Greedy
  2. Divide and conquer
  3. Dynamic programming
  4. None of greedy, divide and conquer, or dynamic programming

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) Dynamic programming

Explanation

Let $D^{(k)}_{ij}$ restrict intermediate vertices to the first k. Its recurrence is $D^{(k)}_{ij}=\min(D^{(k-1)}_{ij},D^{(k-1)}_{ik}+D^{(k-1)}_{kj})$. Combining stored smaller subproblems is dynamic programming, C.

More Dynamic Programming questions

All Dynamic Programming questions →