adplus-dvertising

Welcome to the Graphs MCQs Page

Dive deep into the fascinating world of Graphs with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Graphs, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Graphs, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Graphs. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Graphs. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Graphs MCQs | Page 12 of 17

Q111.
Assuming value of every weight to be greater than 10, in which of the following cases the shortest path of a directed weighted graph from 2 vertices u and v will never change?
Discuss
Answer: (c).multiply all values by 10
Q112.
What is the maximum possible number of edges in a directed graph with no self loops having 8 vertices?
Discuss
Answer: (d).56
Q113.
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;
                }

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

Discuss
Answer: (b).b
Q114.
What is the maximum number of edges present in a simple directed graph with 7 vertices if there exists no cycles in the graph?
Discuss
Answer: (c).6
Q115.
Every Directed Acyclic Graph has at least one sink vertex.
Discuss
Answer: (a).True
Q116.
With V(greater than 1) vertices, how many edges at most can a Directed Acyclic Graph possess?
Discuss
Answer: (a).(V*(V-1))/2
Q117.
The topological sorting of any DAG can be done in ________ time.
Discuss
Answer: (c).linear
Q118.
If there are more than 1 topological sorting of a DAG is possible, which of the following is true.
Discuss
Answer: (b).No Hamiltonian path is possible
Q119.
What would be the output of the following C++ program if the given input is

0 0 0 1 1

0 0 0 0 1

0 0 0 1 0

1 0 1 0 0

1 1 0 0 0
#include <bits/stdc++.h>
using namespace std;
bool visited[5];
int G[5][5];
 
void fun(int i)
{
	cout<<i<<" ";
	visited[i]=true;
	for(int j=0;j<5;j++)
		if(!visited[j]&&G[i][j]==1)
			fun(j);
}
 
int main()
{   
	for(int i=0;i<5;i++)
		for(int j=0;j<5;j++)
			cin>>G[i][j];
 
	for(int i=0;i<5;i++)
		visited[i]=0;
 
	fun(0);
		return 0;
}
Discuss
Answer: (b).0 3 2 4 1
Discuss
Answer: (a).All the Cyclic Directed Graphs have topological sortings

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!