• edited by
13,032 views
48 48 votes

A sink in a directed graph is a vertex i such that there is an edge from every vertex $j \neq 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 expression for $E_3$

  1. $(A[i][j] \ \&\& \ !A[j][i])$
  2. $(!A[i][j] \ \&\& \ A[j][i])$
  3. $(!A[i][j] \ \left | \right | A[j][i])$
  4. $(A[i][j] \ \left | \right | \ !A[j][i])$

8 Answers

Answer:
Position:
Show:

Related questions

48 48 votes
5 answers 5 answers
16.0k
16.0k views
Ishrat Jahan asked Nov 3, 2014
16,039 views
A sink in a directed graph is a vertex i such that there is an edge from every vertex $j \neq i$ to $i$ and there is no edge from $i$ to any other vertex. A directed grap...
94 94 votes
17 answers 17 answers
29.8k
29.8k views
Ishrat Jahan asked Nov 3, 2014
29,811 views
In a depth-first traversal of a graph $G$ with $n$ vertices, $k$ edges are marked as tree edges. The number of connected components in $G$ is$k$$k+1$$n-k-1$$n-k$
33 33 votes
2 answers 2 answers
8.5k
8.5k views
Ishrat Jahan asked Nov 3, 2014
8,507 views
In the following table, the left column contains the names of standard graph algorithms and the right column contains the time complexities of the algorithms. Match each ...
69 69 votes
6 answers 6 answers
20.0k
20.0k views
Ishrat Jahan asked Nov 3, 2014
20,000 views
Let $a$ and $b$ be two sorted arrays containing $n$ integers each, in non-decreasing order. Let $c$ be a sorted array containing $2n$ integers obtained by merging the two...