Analyse the running time of the following algorithm in big-O notation. You may use either the exact summation method, or the rules of thumb. An undirected weighted graph G = (V, E) with n vertices (|V| = n). An n times n matrix containing the length of the shortest path between each pair of vertices, D = a n times n matrix of minimum distances initialized to infinity for each vertex v do D[v][v] = 0 for each edge (u, v) do D[u][v] = D[v][u] = w(u, v) (w(u, v) is the weight of edge (u, v)) for k = 1 to n do for I = 1 to n do for j = 1 to n do if D[i][j] > D[i][k] + D[k][j], then D[i][j] = D[i][k] + D[k][j] return D Solution Answer is O(n 3 ) Explanation to answer: ------------------------------- Each for loop will iterate for (n+1) times. So.. in given algorithm there are three for loops which are placed inside each other. So the total steps are.. for each verted v do ---------> (n+1) times D[v][v] = 0 for each edge {u,v} do ---------> (n+1) times D[u][v] = D[e][u] = w{u,v}{w{u,v} is the weight of edge {u,v}} for k=1 to n do ---------> (n+1) times for i=1 to n do ---------> (n+1) times for j=1 to n do ---------> (n+1) times So totally.. (n+1) + (n+1) + (n+1)*(n+1)*(n+1) 2n + 2 + (n 2 + 2n + 1) * (n+1) ==> 2n + 2 + n 3 + 3n 2 + 3n + 1 For complexity we will consider highest degree... so O(n 3 ) .