What Would Be The Value Of The Distance Matrix After The #1254
What would be the value of the distance matrix, after the execution of the given code?</p> <pre><code class="language-cpp"> #include <bits/stdc++.h> #define INF 1000000 int graph[V][V] = { {0, 7, INF, 4}, {INF, 0, 13, INF}, {INF, INF, 0, 12}, {INF, INF, INF, 0} }; int distance[V][V], i, j, k; for (i = 0; i < V; i++) for (j = 0; j < V; j++) distance[i][j] = graph[i][j]; for (k = 0; k < V; k++) for (i = 0; i < V; i++) for (j = 0; j < V; j++) { if (distance[i][k] + distance[k][j] < distance[i][j]) distance[i][j] = distance[i][k] + distance[k][j]; return 0; } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Graph - Directed Graph - Quiz No.1.
What would be the value of the distance matrix, after the execution of the given code?
#include <bits/stdc++.h> #define INF 1000000 int graph[V][V] = { {0, 7, INF, 4}, {INF, 0, 13, INF}, {INF, INF, 0, 12}, {INF, INF, INF, 0} }; int distance[V][V], i, j, k; for (i = 0; i < V; i++) for (j = 0; j < V; j++) distance[i][j] = graph[i][j]; for (k = 0; k < V; k++) for (i = 0; i < V; i++) for (j = 0; j < V; j++) { if (distance[i][k] + distance[k][j] < distance[i][j]) distance[i][j] = distance[i][k] + distance[k][j]; return 0; }
{ {0, 7, INF, 4}, {INF, 0, 13, INF}, {INF, INF, 0, 12}, {INF, INF, INF, 0} };
{ {0, 7, 20, 24}, {INF, 0, 13, 25}, {INF, INF, 0, 12}, {INF, INF, INF, 0} };
{ {0, INF, 20, 24}, {INF, INF, 13, 25}, {INF, INF, 0, 12}, {INF, INF, INF, 0} {INF, 0, 13, 25}, {INF, INF, 0, 12}, {24, INF, INF, 0} };
None of the mentioned
Similar question(s) are as followings:
Online Quizzes of gs121 Data Structures and Algorithms
Binary Trees - Binary Search Tree - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Binary Search Tree - Quiz No.2
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Preorder Traversal - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes