GATE 2007
184 questions
MCQ 1841-mark 184
Questions 101–105 of 184
A depth-first search is performed on a directed acyclic graph. Let d[u] denote the time at which vertex u is visited for the first time and f[u] the time at which the DFS call to the vertex u terminates. Which of the following statements is always TRUE for all edges (u, v) in the graph ?
Answer: (D)
Why D always holds. Take any edge . When DFS scans this edge from , either is not yet visited or it is already finished. It cannot be still in progress, because that would be a back edge and a DAG has no cycle. If is not yet visited, it is visited inside the call of and ends before ends. If is already finished, it ended even earlier. Either way .
Why A, B and C can fail. Use the DAG in the figure, with edges , and . Start DFS at first: . Then start at : , go to : . The edge leads to a finished vertex, so , .
For the edge : (A fails), (B fails), (C fails), while holds.
Answer: (D)
Consider the DAG with V = {1,2,3,4,5,6}, shown below.
Which of the following is NOT a topological ordering?
Which of the following is NOT a topological ordering?
Answer: (D)
The edges are . In a topological order, every edge must have before . Vertex 1 is the only source, so it must come first.
(A) 1 2 3 4 5 6: 1 is before 2 and 3; 2 and 3 are before 4; 4 is before 5 and 6; 2 is before 5; 3 is before 6. Valid.
(B) 1 3 2 4 5 6: the same checks hold. Valid.
(C) 1 3 2 4 6 5: 5 and 6 can be in either order, since there is no edge between them. Valid.
(D) 3 2 4 1 6 5: the edges and need 1 before 2 and 3, but here 3, 2 and 4 all come before 1. Not valid.
Answer: (D)
(A) 1 2 3 4 5 6: 1 is before 2 and 3; 2 and 3 are before 4; 4 is before 5 and 6; 2 is before 5; 3 is before 6. Valid.
(B) 1 3 2 4 5 6: the same checks hold. Valid.
(C) 1 3 2 4 6 5: 5 and 6 can be in either order, since there is no edge between them. Valid.
(D) 3 2 4 1 6 5: the edges and need 1 before 2 and 3, but here 3, 2 and 4 all come before 1. Not valid.
Answer: (D)
What is the largest integer m such that every simple connected graph with n vertices and n edges contains at least m different spanning trees ?
Answer: (C)
A connected graph with n vertices and n edges has exactly one cycle (a spanning tree has edges, so there is one extra edge).
A spanning tree is got by removing exactly one edge, and the removed edge must be on the cycle (otherwise the graph is disconnected or the cycle stays). Removing a different cycle edge gives a different tree. So the number of spanning trees equals the length of the cycle.
In a simple graph a cycle has at least 3 edges, so every such graph has at least 3 spanning trees.
This graph (a triangle with one extra edge, ) has a cycle of length 3, so it has exactly 3 spanning trees. So 3 is reached, and no such graph has fewer. The largest m is 3. Option (D), n, is too big: this graph has but only 3 spanning trees.
Answer: (C)
A spanning tree is got by removing exactly one edge, and the removed edge must be on the cycle (otherwise the graph is disconnected or the cycle stays). Removing a different cycle edge gives a different tree. So the number of spanning trees equals the length of the cycle.
In a simple graph a cycle has at least 3 edges, so every such graph has at least 3 spanning trees.
This graph (a triangle with one extra edge, ) has a cycle of length 3, so it has exactly 3 spanning trees. So 3 is reached, and no such graph has fewer. The largest m is 3. Option (D), n, is too big: this graph has but only 3 spanning trees.
Answer: (C)
Let w be the minimum weight among all edge weights in an undirected connected graph. Let e be a specific edge of weight w . Which of the following is FALSE?
Answer: (D)
Let be any MST. If , adding to makes one cycle. Every other edge on that cycle has weight , since is the minimum. If were heavier than , then would be a lighter spanning tree, which is impossible. So every other edge on the cycle weighs exactly .
(B) True. This is exactly the statement just shown.
(A) True. Since the other cycle edge also weighs , has the same weight as , so it is an MST containing .
(C) True. If , has a weight- edge. If not, the cycle above has another edge of weight in .
(D) False. In a triangle with all three edges of weight 1, each MST uses two edges and leaves the third out, so a given edge is missing from some MST.
Answer: (D)
(B) True. This is exactly the statement just shown.
(A) True. Since the other cycle edge also weighs , has the same weight as , so it is an MST containing .
(C) True. If , has a weight- edge. If not, the cycle above has another edge of weight in .
(D) False. In a triangle with all three edges of weight 1, each MST uses two edges and leaves the third out, so a given edge is missing from some MST.
Answer: (D)
Consider a weighted, undirected graph with positive edge weights and let be an edge in the graph. It is known that the shortest path from the source vertex to has weight 53 and the shortest path from to has weight 65. Which one of the following statements is always TRUE?
Answer: (C)
Let be the shortest distance from to . We have and .
Going from to by a shortest path and then taking the edge is one path from to , so , that is . So .
Option (D) is not always true: is possible (if the shortest path to goes through ). Options (A) and (B) are not always true either: can be larger than 12, for example 100, if is reached by another path of weight 65.
Answer: (C)
Going from to by a shortest path and then taking the edge is one path from to , so , that is . So .
Option (D) is not always true: is possible (if the shortest path to goes through ). Options (A) and (B) are not always true either: can be larger than 12, for example 100, if is reached by another path of weight 65.
Answer: (C)