Abstract
Suppose you are running a conference and you have a collection of events (or talks) that each have a start time and an end time. However, there is only one conference room available. Goal: schedule the most events possible that day such that no two events overlap.
- Category: Greedy Algorithm / Interval Scheduling
- Input: A collection of events, each with a start and finish time
- Output: A subset of events, none overlapping
- Paradigm: Greedy (Earliest End Time strategy)
- Typical use cases: room/resource booking, single-machine job scheduling, any “pick the max number of non-conflicting intervals” problem
Core Logic (High-Level)
Specification
- Instance: collection of events
- Solution Format: subset of events
- Constraints: no 2 events in the subset overlap
- Objective: cardinality of the subset ()
- Goal: maximize
Strategies to Solve
Before solving and proving a greedy algorithm, we should first find a greedy strategy to solve. Several candidate greedy strategies:
- Shortest duration ✘ — Counter Example: Solution , Better Solution .

- Earliest start time ✘ — Counter Example: Solution , Better Solution .

- Fewest conflicts ✘ — Solution: 3, Better Solution: 4.

- Earliest end time ✔ — Solution: 4 (optimal).

Key Idea
Picking the event that finishes soonest leaves the maximum possible remaining time for everything else — it’s the choice that constrains the future the least. That’s exactly why the other three strategies fail: shortest duration, earliest start, and fewest conflicts can all still “use up” time that a later, more useful event needed.
Pseudocode (Mid-Level Implementation)
Algorithm 43 Event Scheduling Implementation
procedure EventScheduling()
Initialize a Queue
Sort the intervals by finish time
Put the first event in
Set
for do
if then
enqueue()
return
Variables & Data Structures
| Name | Type | Purpose |
|---|---|---|
S | Queue | Accumulates the chosen (non-overlapping) events, in order |
F | Number | The finish time of the most recently accepted event — the earliest time the room becomes free next |
E_i | Event | The event currently being considered, in sorted order |
Helper Functions / Operations Used
- Sort by finish time — a one-time pass that makes the rest of the algorithm a single linear scan
enqueue(E_i, S)— accepts event into the schedule;
Proof of Correctness
We need to show: for every instance , letting be the greedy algorithm’s solution to and be any other solution for ,
(since this is a maximization problem — cardinality of the chosen subset).
The Tricky Part
is an arbitrary solution, not one that makes sense to reason about directly — we don’t know much about it. This is what makes greedy optimality proofs harder than they first look, and why general techniques exist rather than ad hoc arguments each time.
Two of the three general techniques (see Techniques to Prove Optimality for the complete overview of all three) apply cleanly here, giving two independent proofs of the same result.
Proof via Exchange Argument
Let be the set of all events, with the start and finish times of . Let be the event with the earliest finish time — the first greedy decision (include ). Let be any non-overlapping schedule that does not include .
Claim: there is a schedule that does include such that .
Proof: let the events in be , ordered by start and finish time ().

Define from :
is valid (no overlapping events): since is valid, no pair overlaps — so it’s enough to show doesn’t overlap (the event right after ). Since is valid, . And since is defined as the event with the earliest finish time overall, . So doesn’t overlap , and is valid.
: removes exactly one event () from and adds exactly one () back in, so — is always at least as good (equal count), never worse.
Induction: this Exchange Argument claim alone doesn’t prove optimality — it needs an inductive argument on top. Prove by strong induction on nn n, the number of events:
- Base Case (): any choice works, including the greedy choice.
- Inductive Hypothesis: suppose , and the greedy algorithm is optimal for any events, — i.e. for , for any solution .
- Inductive Step: let be any solution on . By the Exchange Argument above, there’s a solution with that includes the first greedy choice . Let be the events that don’t conflict with , so for some solution of . Since , the inductive hypothesis gives . By definition, . Putting it together:
So the greedy algorithm is optimal for any .
Proof via Greedy Stays Ahead
Consider input with events. Let be an arbitrary set of non-conflicting events (in order), and let be the greedy strategy’s output. Want to show: , i.e. .

Compare a progress measure — when the event finishes.
Claim: “stays ahead” of : for all .
Proof (induction on ):
- Base Case: by the greedy choice (earliest finish time overall).
- Inductive Hypothesis: for some , assume .
- Inductive Step: want . Among all events that start after finishes, is chosen to be the one that ends earliest. Since starts after finishes (validity of ), and (inductive hypothesis, then validity of ), is a candidate the greedy strategy could have picked at step — and since greedy picks the earliest-finishing candidate, .
Using this to prove (by contradiction): suppose (so has more events than ). Then is the last greedy choice, so no event starts after finishes. By the Claim, , and by validity of , . This implies there’s an event, that starts after the last greedy choice finishes — but greedy would have picked it, contradicting that was the last choice. So , meaning .
Both proofs conclude the same thing — Earliest End Time is optimal — via genuinely different routes: Exchange inducts on shrinking the problem size, while Greedy Stays Ahead inducts on the sequence of choices itself. See Techniques to Prove Optimality for how these two techniques generalize beyond this example.
Time & Space Complexity Analysis
General Case
| Complexity | Notes | |
|---|---|---|
| Time | Dominated by sorting the events by finish time; the single linear pass afterward is | |
| Space | Storage for the sorted event list plus the output queue |
Best / Worst / Average Case
- Best / Worst / Average case: All — sorting must happen regardless of how many events end up overlapping, and the linear scan afterward always touches every event once.
Drawbacks / Constraints
- The correct greedy criterion isn’t obvious. Three plausible-looking strategies (shortest duration, earliest start time, fewest conflicts) all fail — see the counterexamples above — which is exactly the general warning in Greedy Algorithms: a greedy algorithm needs a proof, not just intuition, before you can trust it.
- Not suitable for: weighted interval scheduling (maximizing total value of chosen events rather than just their count) — earliest-end-time is no longer guaranteed optimal once events have different weights; that variant requires Dynamic Programming instead.
- Preconditions: assumes a single resource (one conference room); scheduling across multiple identical rooms is a related but different problem (interval partitioning).