MIT 6.1220 — Lecture 1
Greedy and DP
Problem. (Interval Scheduling) Consider a set of requests , where:
Every request is an open interval with real number endpoints .
Two requests are compatible if they do not intersect.
Determine any largest possible subset of mutually compatible requests.
Example. If , then any one of , , or is an optimal solution.
Solution. (Interval Scheduling) Greedily pick the compatible requests that end earliest.
Proof: We define the following:
Let be the ordered greedy solution (sorted by endpoint).
Let be the ordered optimal solution (sorted by endpoint).
If , then we win. Otherwise, let be the first index where and differ.
Claim 1. If , then . This is because is assumed compatible with .
Claim 2. We must have . This is because the greedy algorithm picked , not .
Claim 3. By Claim 1 and Claim 2, the optimal solution can be adjusted like so:
By repeatedly applying Claim 3, we see is an optimal solution. But is impossible! If it were, the greedy algorithm would have added , yet it didn't. So .
Problem. (Weighted Interval Scheduling) Consider a set of requests together with weights . Determine any heaviest possible subset of compatible weighted requests.
Solution. (Weighted Interval Scheduling) Just use DP. Sort the intervals by start time. Then:
where is the least index for which does not intersect . Repeat, recurse, blah blah.
Remark. For any , how can you find in time?
How can you find all the in time, given the ordering of all interval endpoints?
Problem. (Online Interval Scheduling) Determine any largest possible subset of mutually compatible requests, given that requests come one at a time (in any order!) and must be accepted or rejected on arrival.
Unfortunately, an adversary can force the algorithm solver to always fail horribly. (Why?)
Problem. (Randomized Online Interval Scheduling) Say the set of requests is fixed. Now the algorithm receives these requests in a randomized order.
We'll figure out the solution to this updated problem during Probability Review on Sunday.