GATE 2005
203 questions
MCQ 2031-mark 203
Questions 116–120 of 203
Are all tasks completed in the schedule that gives maximum profit?
Answer: (D)
Sort the tasks by profit, highest first. For equal profit put the later deadline first ( before ). Put each task in the latest free slot at or before its deadline. If no such slot is free, leave the task out. Slot means the time from to . The latest deadline is 7, so there are 7 slots.
cannot use slot 2 (taken by ), so it takes slot 1. has deadline 3, and slots 1, 2 and 3 are already full, so it is left out. takes slot 7 and takes slot 6, so slots 1 to 7 are now full. has deadline 5, and slots 1 to 5 are full, so it is left out too.
The profit is . Only and are left out.
Answer: (D)
Answer: (A)
1. Bellman-Ford: it runs rounds, and each round relaxes all edges, so (C).
2. Kruskal: sorting the edges costs , which is because ; the union-find steps cost no more. So (A).
3. Floyd-Warshall: three nested loops over all vertices, so (B).
4. Topological sorting: one DFS (or repeated removal of zero in-degree vertices) visits each vertex and edge once, so (D).
So 1 to C, 2 to A, 3 to B, 4 to D.
Answer: (A)
Answer: (D)
The figures show a DFS on a directed example graph with 8 vertices. Solid lines are tree edges; dashed and dotted lines are cross, forward and back edges, which are not tree edges. The 6 tree edges (a-b, a-c, b-d, d-e, e-f, g-h) form 2 DFS trees, one rooted at a and one at g, and . In general, n - k counts the trees in the DFS forest. That count equals the number of connected components when the graph is undirected, which is how the question is read. (In a directed graph like the figure, the 2 trees do not match the strongly connected components.)
In an undirected graph, one DFS tree covers exactly one connected component, because DFS from a root reaches every vertex of its component and no other.
Let there be components, and let component have vertices. A tree on vertices has edges, so component gives tree edges.
Total:
So .
Answer: (A)
Remove from . It splits into two connected parts and . Any edge of G between and weighs at least , since otherwise swapping it for gives a lighter spanning tree. No edge weighs more than , as is the maximum. So every edge between and weighs exactly . These edges form a cutset whose edges all have maximum weight. So (A) is always true.
(B) False. If G is a tree (no cycle), its only spanning tree contains .
(C) False. In a triangle with all edges of equal weight, an MST can contain although lies on a cycle.
(D) False. A path graph with different edge weights has only one spanning tree, which contains the heaviest edge.
Answer: (A)
Let the weight of an edge e denote the congestion on that edge. The congestion on a path is defined to be the maximum of the congestions on the edges of the path. We wish to find the path from s to t having minimum congestion. Which one of the following paths is always such a path of minimum congestion?
Answer: (A)
Why the MST path works. Let be the heaviest edge on the s-t path in the MST. Removing splits the MST into two parts, one holding s and one holding t. is the lightest edge of G between the two parts, otherwise a lighter edge would give a lighter spanning tree. Any other s-t path must cross between the parts, so it has an edge at least as heavy as . So the MST path has the least congestion.
(B) fails. In the figure the shortest path is the direct edge s-t of weight 6, with congestion 6. The MST has the edges of weights 2, 3 and 4. Its s-t path s-B-t has total weight 7 but congestion , which is lower.
(C), (D) fail. An Euler walk or a Hamiltonian path is fixed by which edges and vertices it must visit, not by weight, so nothing keeps heavy edges out. Here the Euler walk s-B-t-s-C-t must use the weight-6 edge, and no Hamiltonian path from s to t exists.
Answer: (A)