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?

  1. A. III and IV only
  2. B. IV only
  3. C. II and IV only
  4. 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

Exams that ask this topic