Question: The dynamic programming algorithm of Algorithm 14.11 uses O(n 3 ) space. Describe a version of this algorithm that uses O(n 2 ) space. Algorithm
The dynamic programming algorithm of Algorithm 14.11 uses O(n3) space. Describe a version of this algorithm that uses O(n2) space.
Algorithm 14.11
![Algorithm AllPairsShortestPaths(G): Input: A simple weighted directed graph G without negative-weight cycles Output: A numbering v1, v2, ..., Un of the vertices of G and a matrix D, such that D[i, j] is the distance from vị to v; in G let v1, v2, ..., Vn be an arbitrary numbering](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1595/3/1/4/3715f1690c3bc1531595314367241.jpg)
Algorithm AllPairsShortestPaths(G): Input: A simple weighted directed graph G without negative-weight cycles Output: A numbering v1, v2, ..., Un of the vertices of G and a matrix D, such that D[i, j] is the distance from v to v; in G let v1, v2, ..., Vn be an arbitrary numbering of the vertices of G for i 1 to n do for j +1 to n do if i = j then D[i, i] 0 if (v;, v;) is an edge in G then D[i, j] w(v;, v;)) else Dli, j] - +o for k + 1 to n do for i - 1 to n do for j 1 to n do D*[i, j] - min{Dk-1[i, j], Dk-1[i, k] + Dk-1{k, j]} return matrix D"
Step by Step Solution
3.44 Rating (160 Votes )
There are 3 Steps involved in it
To reduce the space complexity of Algorithm 1411 from On3 to On2 we can mak... View full answer
Get step-by-step solutions from verified subject matter experts
