Question
#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;
}
a)
{
{0, 7, INF, 4},
{INF, 0, 13, INF},
{INF, INF, 0, 12},
{INF, INF, INF, 0}
};
b)
{
{0, 7, 20, 24},
{INF, 0, 13, 25},
{INF, INF, 0, 12},
{INF, INF, INF, 0}
};
c)
{
{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}
};
d) None of the mentioned
a.
a
b.
b
c.
c
d.
d
Posted under Data Structures and Algorithms
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What would be the value of the distance matrix, after the execution of the given code?
Similar Questions
Discover Related MCQs
Q. What is the maximum number of edges present in a simple directed graph with 7 vertices if there exists no cycles in the graph?
View solution
Q. Every Directed Acyclic Graph has at least one sink vertex.
View solution
Q. With V(greater than 1) vertices, how many edges at most can a Directed Acyclic Graph possess?
View solution
Q. The topological sorting of any DAG can be done in ________ time.
View solution
Q. If there are more than 1 topological sorting of a DAG is possible, which of the following is true.
View solution
Q. Which of the given statement is true?
View solution
Q. For any two different vertices u and v of an Acyclic Directed Graph if v is reachable from u, u is also reachable from v?
View solution
Q. What is the value of the sum of the minimum in-degree and maximum out-degree of an Directed Acyclic Graph?
View solution
Q. In which of the following does a Directed Acyclic Word Graph finds its application in?
View solution
Q. What is time complexity to check if a string(length S1) is a substring of another string(length S2) stored in a Directed Acyclic Word Graph, given S2 is greater than S1?
View solution
Q. In which of the following case does a Propositional Directed Acyclic Graph is used for?
View solution
Q. Every Binary Decision Diagram is also a Propositional Directed Acyclic Graph.
View solution
Q. In a Propositional Directed Acyclic Graph Leaves maybe labelled with a boolean variable.
View solution
Q. Given Adjacency matrices determine which of them are PseudoGraphs?
i) {{1,0} {0,1}}
ii) {{0,1}{1,0}}
iii) {{0,0,1}{0,1,0}{1,0,0}}
View solution
Q. All undirected Multigraphs contain eulerian cycles.
View solution
Q. Determine the number of vertices for the given Graph or Multigraph?
G is a 4-regular Graph having 12 edges.
View solution
Q. Which of the following statement is true.
View solution
Q. Given Adjacency matrices determine which of them are PseudoGraphs?
i) {{1,0} {0,1}}
ii) {{0,1}{1,0}}
iii) {{0,0,1}{0,1,0}{1,0,0}}
View solution
Q. Possible number of labelled simple Directed, Pseudo and Multigarphs exist having 2 vertices?
View solution
Q. Which of the following is a HyperGraph, where V is the set of vertices, E is the set of edges?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!