CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

A sink in a directed graph is a vertex i such that there is an edge from every vertex ji to i and there is no edge form i to any other vertex. A directed graph G with n vertices is represented by its adjacency matrix A, where A[i] [j] = 1 if there is an edge directed from vertex i to j and 0 otherwise.

The following algorithm determines whether there is a sink in the graph G.

i=0;
do
{
j = i + 1;
while (j <n) && E1)
j++;
if (j <n) E2;
}
while (i < n);
flag = 1;
for (j = 0; j < n; j++)
if ((j! = i) && E3)
flag = 0;
if (flag)
printf(“Sink exists”);
else
printf (“Sink does not exist”);

Choose the correct expressions for E1 and E2

A
E1 : !A[i] [j] and E 2 : i = j + 1 ;
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
E1 : !A[i] [j] and E 2 : i = j + 1 ;
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
E1 : A[i] [j] and E 2 : i = j ;
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
E1 : A[i] [j] and E 2 : i = j ;
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is C E1 : A[i] [j] and E 2 : i = j ;
A sink in a directed graph is a vertex such that there is an edge from every other vertex j i to i and there is no edge from i to any other vertex.


In above image 'd' is sink i.e. there is no outgoing edge by checking row of all vertex if we find any row with all zero then we find a potential vertex for sink.

While ((j < n) && !A[i] [j]) will check every entry row is 0 or not and until it find 1 in row, increment j.

If it find 1 in row skip a row by which it does not have any incoming edge by doing i = j.

flag
Suggest Corrections
thumbs-up
0
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon