Interval Scheduling

Unweighted Algorithm

Problem: Job starts at and finishes at . Goal is to find maximum set of jobs that do not overlap.

Algorithm: Sorts jobs by finish time (ascending) and then go through the list, taking compatible jobs (Greedy Algorithms)

Time complexity: due to that sorting step at the start

Theorem

The earliest-finish-time-first algorithm is optimal

Proof:

  • Assume by way of contradiction, that the greedy algorithm is not optimal.
  • Let denote the set of jobs selected by greedy.
  • Let denote the set of jobs in an optimal solution that agrees with the greedy solution on the most jobs with for largest possible value of .
  • We know and exist because the optimal solution has more jobs and there is a conflict in greedy solution causing it to not pick .
  • The greedy solution has elements with the earliest finish time, so we can replace with and it would not overlap with any other elements, so the solution is still optimal.
  • Repeat until the solutions are equal
  • Therefore, the greedy solution is optimal. A contradiction.

Weighted Algorithm

Needs dynamic algorithm