gs gs121 Graph - Directed Graph - Quiz No.1
gs gs121 Data Structures and Algorithms Quiz
This quiz belongs to book/course code gs gs121 Data Structures and Algorithms of gs organization. We have 169 quizzes available related to the book/course Data Structures and Algorithms. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Graph. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
#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} };