ProgrammingVery hardCAT · MBA placement

You must choose the maximum number of non-overlapping activities, each with a start and a finish time. Which greedy rule is correct?

  1. A. Sort by start time and take each activity that starts after the last chosen start
  2. B. Sort by duration, shortest first, and take every compatible activity
  3. C. Sort by finish time and take each activity whose start is at least the last chosen finish
  4. D. Pick the activity that overlaps the fewest others, then remove overlaps and repeat

Correct answer: C. Sort by finish time and take each activity whose start is at least the last chosen finish

Earliest finish is the correct greedy choice because it leaves the most room for later activities. Sorting by start or duration can pick one long activity that blocks several short ones.

More Python Programming questions

Exams that ask this topic