Data Structures & AlgorithmsModerateProduct-company MCQ pattern

In the activity selection problem (choose the most non-overlapping intervals), which greedy rule always gives an optimal answer?

  1. A. Pick the activity with the fewest overlaps
  2. B. Pick the shortest activity first
  3. C. Pick the activity that finishes earliest, then repeat on the compatible ones
  4. D. Pick the activity that starts earliest

Correct answer: C. Pick the activity that finishes earliest, then repeat on the compatible ones

Taking the earliest finish leaves the most room for the rest, and an exchange argument shows it never hurts. Earliest start and shortest first both have easy counterexamples.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic