Chapter 1: Introduction to Interval Scheduling and Complexity
Source files used: Intro_ocw (Lecture 1 notes), Matrix Multiplication (Recitation 1, Section 1 only), MIT6_046JS15_pset1 (Problem 1-1 as practice). No worked examples are included.
1. Big Picture
The first lecture is about one idea: very similar problems can have very different complexity.
The lectures show this with one family of scheduling problems:
- unweighted interval scheduling: a simple greedy algorithm is optimal,
- weighted interval scheduling: greedy fails, dynamic programming works in ,
- interval scheduling on non-identical machines: NP-complete.
The course modules that follow: divide and conquer (FFT, randomized algorithms), optimization (greedy, dynamic programming), network flow, intractability, linear programming, sublinear and approximation algorithms, advanced topics. The prerequisite is 6.006 material: heaps, trees, graphs, sorting, shortest paths, graph search, dynamic programming.
2. Core Ideas
2.1 P, NP, NP-Complete
P: problems solvable in polynomial time, for some constant (shortest paths, ).
NP: problems whose solutions can be verified in polynomial time.
NP-complete: in NP, and as hard as any problem in NP.
. Whether is open. If any NP-complete problem has a polynomial-time solution, then every problem in NP does.
Example from the lectures: deciding whether a directed graph has a Hamiltonian cycle (a simple cycle through every vertex) is NP-complete, but verifying that a given cycle is Hamiltonian is easy.
2.2 Interval Scheduling Setup
Requests share a single resource. Request has start time and finish time , with .
Two requests and are compatible if they do not overlap:
Goal: select a compatible subset of maximum size.
2.3 Greedy Algorithms
A greedy algorithm is myopic: it processes the input one piece at a time with no apparent look-ahead.
Greedy template for interval scheduling:
- Use a simple rule to select a request .
- Reject all requests incompatible with .
- Repeat until all requests are processed.
The whole question is which rule. Only one of the four candidate rules works (Section 5.1).
2.4 Why Greedy Breaks with Weights
Each request now has a weight , and the goal is a compatible subset of maximum total weight.
Lecture counterexample: two short requests with each and one overlapping request with . Earliest finish time picks the two requests (total 2) instead of the single request. Greedy no longer works; use dynamic programming.
2.5 Dynamic Programming by Guessing
Subproblems are suffixes of time:
If , then is the set of requests that start after request finishes. There are different subproblems, one per request. Solve each once and memoize.
Guess: try each request as the first request. Then the remaining requests are . Some requests compatible with may not be in , but that is fine because is being picked as the first one (requests are taken in order).
2.6 Dealing with Intractability
When a problem is NP-hard, the lectures list three options:
- Approximation algorithms: guaranteed within some factor of optimal, in polynomial time.
- Pruning heuristics: reduce a (possibly exponential) runtime on real-world inputs.
- Greedy or other suboptimal heuristics: work well in practice, no guarantees.
3. Main Governing Equations and Formulas
3.1 Compatibility Condition
Use to decide whether two requests can both be scheduled. Touching endpoints () count as compatible.
3.2 Greedy Output Structure (Claim 1)
Earliest-finish-time greedy outputs intervals with
Proof: if , intervals and intersect, which contradicts step 2 of the algorithm (incompatible requests were rejected).
Use to argue the greedy output is a valid (compatible) schedule.
3.3 Greedy Optimality (Claim 2)
Given a list of intervals , greedy with earliest finish time produces intervals, where is optimal.
Proof is by induction on . The key exchange step: greedy’s first interval finishes no later than the optimal schedule’s first interval,
so swapping for in the optimal schedule keeps it valid and optimal. The full proof is in the Induction guide (Section 3.4 there).
Use when asked to prove a greedy rule is optimal.
3.4 Weighted Interval Scheduling: Lecture Recurrence
Running time: ( subproblems, choices each).
Use as the DP definition when the problem is weighted.
3.5 Weighted Interval Scheduling: Recitation Version
Sort requests by finish time:
Define as the largest index such that requests and are compatible. is the maximum weight using requests to .
M[0] = 0
for j = 1 to n
M[j] = max(w(j) + M[p(j)], M[j-1])
Costs: sorting , filling is , tracing back the chosen set . Total .
Use this version when the question asks for the fastest algorithm. The two branches of the max are “take ” and “skip “.
3.6 Non-Identical Machines
Requests with , as before, weight 1 each. There are machine types , and is the set of machines request can run on. Goal: maximize the number of jobs scheduled on the machines.
- In NP: any given subset of jobs with machine assignments can be checked for legality.
- Decision version (“can requests be scheduled?”): NP-complete.
- Maximization version: NP-hard.
Use as the lecture’s example of a small change to the problem that makes it intractable.
4. Problem-Solving Workflow
4.1 Designing an Algorithm (Problem Set Format)
The problem sets ask for a short essay, not just code:
- Define the problem and state your result.
- Describe the algorithm in English (pseudocode if helpful).
- Prove correctness (or give a proof sketch).
- Analyze the running time.
Full credit requires a correct solution that is clearly described.
4.2 Attacking a Scheduling-Type Problem
- Check whether a greedy rule could work. Try to break each candidate rule with a small counterexample (Section 5.1).
- If one rule survives, prove it: show the output is valid (Section 3.2), then prove optimality by induction plus an exchange argument (Section 3.3).
- If weights or other structure break greedy, define DP subproblems (Section 2.5) and a recurrence (Section 3.4).
- Speed up the DP with sorting and (Section 3.5).
- If even small variants look hard, check membership in NP and think about NP-completeness (Section 3.6), then pick a way to deal with intractability (Section 2.6).
Practice: Problem Set 1, Problem 1-1 (restaurant placement on a tree) follows exactly this path: break a greedy rule with a counterexample, design an efficient algorithm on trees, prove a simple greedy for the equal-profit case, then consider arbitrary graphs.
5. Decision Rules / Decision Trees
5.1 Which Greedy Rule?
Earliest start time (min )? → fails: one long request that starts first blocks several short ones
Shortest request (min )? → fails: a short request can overlap two longer compatible ones
Fewest incompatibilities? → fails: the lecture gives a layered counterexample
Earliest finish time (min )? → optimal
5.2 Greedy or DP?
Unweighted, maximize the count? → greedy, earliest finish time
Weighted, maximize total weight? → DP:
Requests restricted to machine subsets ? → NP-complete decision version, NP-hard optimization
5.3 Class of a Problem
Can you solve it in ? → in P
Can you only verify a proposed answer in polynomial time? → in NP
In NP AND as hard as every NP problem? → NP-complete
6. Important Tables / Correlations Needed
6.1 Interval Scheduling Variants
| Variant | Method | Time |
|---|---|---|
| Unweighted, one resource | greedy, earliest finish time | sort, then one scan |
| Weighted, lecture DP | ||
| Weighted, recitation DP | sort by , use and | |
| Non-identical machines | none known in poly time | NP-complete / NP-hard |
6.2 Complexity Classes
| Class | Meaning | Lecture example |
|---|---|---|
| P | solvable in polynomial time | shortest paths |
| NP | verifiable in polynomial time | checking a Hamiltonian cycle |
| NP-complete | in NP and as hard as any NP problem | Hamiltonian cycle existence |
| NP-hard | at least as hard as NP-complete (optimization form) | max jobs on non-identical machines |
7. Key Takeaways
- Very similar problems can have very different complexity.
- Two requests are compatible if or .
- Earliest finish time is the only one of the four greedy rules that is optimal.
- Greedy optimality is proved by induction on with the exchange fact .
- Weights break greedy; use DP over subproblems .
- Lecture DP is ; sorting by finish time and gives .
- : take or skip .
- P NP; if any NP-complete problem is in P, then P = NP.
- Scheduling on non-identical machines is NP-complete (decision) and NP-hard (maximize).
- For intractable problems: approximation, pruning heuristics, or heuristics with no guarantee.