Question: Can someone translate this pseudocode to C++ please? ALGORITHM Warshall(A[1..n, 1..n]) //ImplementsWarshalls algorithm for computing the transitive closure //Input: The adjacency matrix A of a
Can someone translate this pseudocode to C++ please?
ALGORITHM Warshall(A[1..n, 1..n]) //ImplementsWarshalls algorithm for computing the transitive closure //Input: The adjacency matrix A of a digraph with n vertices //Output: The transitive closure of the digraph R(0) ?A for k?1 to n do ____for i ?1 to n do ________for j ?1 to n do ____________R(k)[i, j ]?R(k?1)[i, j ] or (R(k?1)[i, k] and R(k?1)[k, j]) return R(n)
and translate this to C++ as well: ALGORITHM Floyd(W[1..n, 1..n]) //Implements Floyds algorithm for the all-pairs shortest-paths problem //Input: The weight matrix W of a graph with no negative-length cycle //Output: The distance matrix of the shortest paths lengths D ?W //is not necessary if W can be overwritten for k?1 to n do ____for i ?1 to n do ________for j ?1 to n do ____________D[i, j ]?min{D[i, j ], D[i, k]+ D[k, j]} return D
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
