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.
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
Explore more Topics under Data Structures and Algorithms
#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
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;
}
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!