Selecting the Right Jobs

Problem Definition

A scheduling problem: you're an actor offered roles in n different films, each specified by a start and end date. You can only work on one film at a time, and each film pays the same amount. Which films should you accept to maximize your total number of jobs?

Formal Statement:

  • Input: A set I of n intervals on the line

  • Output: The largest subset of mutually non-overlapping intervals from I

Movie scheduling instance
circle-check

Failed Heuristics

Earliest Start Time First

Accept jobs in order of their start dates:

Why it fails: A long early job can block many later opportunities.

Shortest Job First

Always accept the shortest available job:

Why it fails: One short job can block two longer jobs that would otherwise fit.

Bad instances for heuristics
triangle-exclamation

We could try all 2ⁿ possible subsets:

This is correct but still impractical. While 2²⁰ ≈ 1 million is manageable, 2¹⁰⁰ is astronomically large—far beyond any computer's reach.

The Optimal Algorithm

The key insight: consider the job that finishes earliest. Any overlapping jobs must conflict with each other, so we can pick at most one from this group. Since the earliest-finishing job blocks the least future time, we should always accept it.

circle-check

Why This Algorithm Works

The earliest-finishing job never blocks more opportunities than any overlapping alternative. By accepting it, we maximize the remaining time available for future jobs. This greedy choice is provably optimal at every step.

Key Insight

Unlike the traveling salesman problem, the movie scheduling problem has an efficient optimal algorithm. The difference lies in problem structure: some problems admit clever solutions that are both fast and correct, while others do not.

circle-exclamation

Finding the right algorithm often requires:

  1. Trying multiple approaches

  2. Constructing counterexamples to reject incorrect heuristics

  3. Identifying key problem properties that enable optimal solutions

  4. Proving correctness rigorously

The contrast between sections 1.1 and 1.2 illustrates a fundamental divide in computer science: some problems are tractable (like interval scheduling), while others remain computationally intractable (like TSP).

Last updated