MIT6 046JS15 Lec01
MIT6 046JS15 Lec01
MIT6 046JS15 Lec01
Lecture 1: Introduction
6.006 pre-requisite:
• Data structures such as heaps, trees, graphs
Course Overview
This course covers several modules:
1. Divide and Conquer - FFT, Randomized algorithms
3. Network Flow
5. Linear programming
7. Advanced topics
1
Lecture 1 Introduction 6.046J Spring 2015
Interval Scheduling
Requests 1, 2, . . . , n, single resource
s(i) start time, f (i) finish time, s(i) < f (i) (start time must be less than finish
time for a request)
Two requests i and j are compatible if they don’t overlap, i.e., f (i) ≤ s(j) or
f (j) ≤ s(i).
In the figure below, requests 2 and 3 are compatible, and requests 4, 5 and 6 are
compatible as well, but requests 2 and 4 are not compatible.
2 3
4 5 6
2
Lecture 1 Introduction 6.046J Spring 2015
Possible rules?
Smallest. Bad :(
3. For each request, find number of incompatibles, and select request with mini
mum such number.
< s(i1 ), f (i1 ) >, < s(i2 ), f (i2 ) >, . . . , < s(ik ), f (ik ) >
such that
s(i1 ) < f (i1 ) ≤ s(i2 ) < f (i2 ) ≤ . . . ≤ s(ik ) < f (ik )
Proof. Simple proof by contradiction – if f (ij ) > s(ij+1 ), interval j and j +1 intersect,
which is a contradiction of Step 2 of the algorithm!
Claim 2. Given list of intervals L, greedy algorithm with earliest finish time produces
k ∗ intervals, where k ∗ is optimal.
Proof. Induction on k ∗ .
Base case: k ∗ = 1 – this case is easy, any interval works.
Inductive step: Suppose claim holds for k ∗ and we are given a list of intervals
whose optimal schedule has k ∗ + 1 intervals, namely
3
Lecture 1 Introduction 6.046J Spring 2015
Say for some generic k, the greedy algorithm gives a list of intervals
By construction, we know that f (i1 ) ≤ f (j1 ), since the greedy algorithm picks the
earliest finish time.
Now we can create a schedule
S ∗∗ =< s(i1 ), f (i1 ) >, < s(j2 ), f (j2 ) >, . . . , < s(jk∗ +1 ), f (jk∗ +1 ) >
since the interval < s(i1 ), f (i1 ) > does not overlap with the interval < s(j2 ), f (j2 ) >
and all intervals that come after that. Note that since the length of S ∗∗ is k ∗ + 1, this
schedule is also optimal.
Now we proceed to define L' as the set of intervals with s(i) ≥ f (i1 ).
Since S ∗∗ is optimal for L, S ∗∗ [2, 3, . . . , k ∗ + 1] is optimal for L' , which implies
that the optimal schedule for L' has k ∗ size.
We now see by our initial inductive hypothesis that running the greedy algorithm
on L' should produce a schedule of size k ∗ . Hence, by our construction, running the
greedy algorithm on L' gives us S[2, . . . , k].
This means k − 1 = k ∗ or k = k ∗ + 1, which implies that S[1, . . . , k] is indeed
optimal, and we are done.
Dynamic Programming
We can define our sub-problems as
Rx = {j ∈ R|s(j) ≥ x}
4
Lecture 1 Introduction 6.046J Spring 2015
Note that even though there may be requests compatible with i that are not in
f (i)
R , we are picking i as the first request, i.e., we are going in order.
Non-identical machines
As before, we have n requests {1, 2, . . . , n}. Each request i is associated with a start
time s(i) and finish time f (i), m different machine types as well τ = {T1 , . . . , Tm }.
Each request i is associated with a set Q(i) ⊆ τ that represents the set of machines
that request i can be serviced on.
Each request has a weight of 1. We want to maximize the number of jobs that
can be scheduled on the m machines.
This problem is in NP, since we can clearly check that a given subset of jobs with
machine assignments is legal.
Can k ≤ n requests be scheduled? This problem is NP-complete.
Maximum number of requests that should be scheduled? This problem is NP-hard.
3. Greedy or other sub-optimal heuristics that work well in practice but provide
no guarantees.
5
MIT OpenCourseWare
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.