Which one of the following algorithm design techniques is used in finding all pairs of shortest distances in a graph?
View worked solution
Answer: A
The standard algorithm for finding all-pairs shortest paths in a weighted graph is the Floyd-Warshall algorithm.
The Floyd-Warshall algorithm is a classic application of the Dynamic Programming design technique. It breaks the problem down into simpler subproblems and solves them bottom-up:
- Let be the shortest path distance from vertex to vertex using only a subset of vertices from the set as intermediate nodes.
- The recurrence relation used to compute the optimal solution is:
Since it computes the shortest paths by reusing previously computed optimal subproblems, it utilizes dynamic programming.
Therefore, the correct option is A.
Free practice · Your answers on this page are not saved.
