Examveda

For which type of graph, the given program won't run infinitely? The Input would be in the form of an adjacency Matrix and n is its dimension (1<n<10).
#include <bits/stdc++.h> 
using namespace std; 
int G[10][10]; 
void fun(int n); 
 
int main()
{
	int num=0; 
	int n; 
	cin>>n; 
	for(int i=0;i<n;i++) 
 		for(int j=0;j<n;j++) 
        		cin>>G[i][j]; 
    	fun(n); 
	return 0; 
}	 
 
void fun(int n)
{ 
	for(int i=0;i<n;i++) 
	for(int j=0;j<n;j++) 
	if(G[i][j]==1) 
	j--; 
}

A. All Fully Connected Graphs

B. All Empty Graphs

C. All Bipartite Graphs

D. All simple graphs

Answer: Option B


This Question Belongs to Data Structure >> Graphs

Join The Discussion

Related Questions on Graphs

What is a cycle in a graph?

A. A path that starts and ends at the same vertex with no other repetitions.

B. A path that includes all vertices exactly once.

C. A path with no edges.

D. A complete traversal of all vertices.