GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Four greedy rules are proposed for choosing the maximum number of mutually non-overlapping activities: I. repeatedly choose the activity with the earliest start time; II. repeatedly choose the shortest activity; III. repeatedly choose the activity with the latest start time; IV. repeatedly choose the activity with the earliest finish time. (After each choice, all conflicting activities are discarded.) Which rules always give an optimal answer?
- A. III and IV only
- B. IV only
- C. II and IV only
- D. I, II and IV only
Correct answer: A. III and IV only
IV is the classical exchange-argument result, and III is its mirror image (time reversed). I fails when a long early activity blocks several short ones, and II fails when a short activity overlaps two long, otherwise compatible ones (random testing against brute force confirmed failures of I and II and none of III and IV).
More Algorithms questions
- Which of the following statements about the 0/1 knapsack problem is/are correct? I. The O(nW) dynamic programme is polynomial in n and in…
- Six tasks have (processing time, deadline): (3,6), (2,8), (4,9), (1,5), (5,15), (2,10). They run one after another on a single machine…
- In how many ways can 12 be written as an ordered sum of parts from {1, 2, 3} such that no two adjacent parts are equal (e.g. 1+2+1+3+… is…
- Which of the following statements about dynamic programming problems is/are correct? I. The LCS of two strings can be computed in O(mn)…
- Ten houses stand in a CIRCLE with values 6, 2, 9, 4, 3, 8, 1, 7, 5, 10 (the first and last houses are neighbours). No two neighbouring…
- Among all full parenthesisations of the product A₁A₂A₃A₄A₅A₆A₇, how many contain the product (A₃A₄) as one of their sub-products?