A sink in a directed graph is a vertex i such that there is an edge from every…
GATE · 2005 · IT
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 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 expression for E3.
- A.
(A[i][j] && !A[j][i])
- B.
(!A[i][j] && A[j][i])
- C.
(!A[i][j] || A[j][i])
- D.
(A[i][j] || !A[j][i])
Attempted by 285 students.
Show answer
Correct answer: D
Explore the full course: Iocl Engineers Officers Grade A Paper 2
Loading lesson…