GATE 2005
203 questions
MCQ 2031-mark 203
Questions 16–20 of 203
where a,b,c,d,e and f are real numbers and abc0. Under the matrix multiplication operation, the set H is:
Answer: (A)
Each matrix is upper triangular, and its determinant is the product of the diagonal entries, . Check the group properties:
- Closed - The product of two upper triangular matrices is upper triangular, and its diagonal entries are the products of the diagonal entries, which are nonzero. Also .
- Associative - Matrix multiplication is always associative.
- Identity - The identity matrix has and , so it is in the set.
- Inverse - The determinant is not zero, so the inverse exists. It is also in the set: , which is upper triangular with nonzero diagonal.
So the set is a group.
Answer: (A)
Answer: (C)
- Inverse of 4: , so it is 4.
- Inverse of 7: , so it is 13.
Answer: (C)
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 .
Answer: (D)
If the graph has a sink, the adjacency matrix has all 1s (except the diagonal) in one column, and all 0s (except the diagonal) in the row of that same vertex. The given algorithm is a smart way to check this, as it finds the only possible sink in time.
The first part of the code finds a vertex that has no outgoing edge to any vertex after it in the adjacency matrix. The smart part of the code is . It skips rows when there is no edge from i to them, because such rows can never form a sink. This is done through
and
;
makes sure that there is no edge from to , and stays a potential sink till becomes . If becomes , then can no longer be a sink. In the same way, all earlier can also not be a sink, since there was no edge from to them and a sink needs an edge from all other vertices. Now the next potential candidate for the sink is . So, in , we must make .
When the loop ends, is the only vertex that can be a sink. The last loop checks every . Vertex is a sink only if (no edge from to ) and (an edge from to ).
The code starts with (sink exists). So must be true when either condition fails for some : (i has an outgoing edge) or (an incoming edge is missing). So
The other options fail:
(A) is true only when both conditions fail, so it misses a vertex where only one fails.
(B) is true exactly when fits a sink, so it would clear the flag for a real sink.
(C) is also true when fits a sink, so it would clear the flag for a real sink too.
Answer: (D)
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 and .
Answer: (C)
If the graph has a sink, its column in the adjacency matrix is all 1's (except the diagonal) and its row is all 0's (except the diagonal). The algorithm finds the only possible sink in time. The options give and , so these are the two expressions to find.
The loop keeps a candidate and scans . It must go on while there is no edge from to , and stop at the first with an edge. So . stays a possible sink while .
When the loop stops at , cannot be a sink, because a sink has no outgoing edge. Every vertex between and cannot be a sink either, because there was no edge from to it and a sink needs an edge from every other vertex. The next possible sink is , so .
The other options fail. (A) and (D) use , which skips while there is an edge, the wrong way round. (B) and (D) use , which skips even though it just received an edge from and may be the sink.
The final loop then checks the candidate. is : if has an edge to , or has no edge to , then is not a sink and the flag becomes 0.
Answer: (C)
Answer: (D)
Tree edges are the edges that end up in the final DFS forest. Take a connected graph, where the DFS forest is just one tree. If we run DFS on it, the edges of that DFS tree are the tree edges.
Say the graph has connected components (strongly connected components if the graph is directed). The 1st component has tree edges, the 2nd has tree edges, and the xth has tree edges.
So the total is:
We can also see it this way. The final DFS forest has trees. These trees have , , edges respectively.
A tree with edges has nodes. In the same way, a tree with edges has nodes, and so on.
So the sum of the nodes in all the trees
Correct Answer: