Fill in the blanks in the following template of an algorithm to compute all…
PYQ GATE 2002Modified — slightly modified from the official paper; see the solution
Fill in the blanks in the following template of an algorithm to compute all pairs shortest path lengths in a directed graph G with n×n adjacency matrix A. Assume A[i,j] is the positive length of the edge from i to j when one exists, and 0 otherwise; the distance from a vertex to itself is 0. Your aim in filling in the blanks is to ensure that the algorithm is correct.
INITIALIZATION: For i = 1 … n
{For j = 1 … n
{ if i=j then P[i,j]=0 else if A[i,j]=0 then P[i,j]=_______ else P[i,j]=____;}
}
ALGORITHM: For i = 1 …n
{ For j = 1 …n
{For k = 1 …n
{P[__,___]=min{_______,_______};}
}
}(a) Copy the complete line containing the blanks in the Initialization step and fill in the blanks. (b) Copy the complete line containing the blanks in the Algorithm step and fill in the blanks. (c) Fill in the blank: The running time of the Algorithm is O(____).
Attempted by 1 students.
Sign up free to check your answer
Sign up freeLoading lesson…

