• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | Gate IT 2005 | Question 88

Q84 Part_A
A sink in a directed graph is a vertex i such that there is an edge from every vertex j ≠ i to i and there is no edge from 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 (j < 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 E2 : i = j;

(B)

E1 : !A[i][j] and E2 : i = j + 1;

(C)

E1: !A[i][j] and E2 : i = j;

(D)

E1 : A[i][j] and E2 : i = j + 1;

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments