Lecture 19 CSE 331 Oct 14, 2011
Announcements Graded HW 4 next Th onwards HW 5 has been posted
Mid Term stuff Graded mid term at the end of the lecture Mid term post up on the blog Read it before asking for regrade requests A temp grade assigned by next week I’ll ask some of you to meet me in person
Sign up for scribe/blog post
Interval Scheduling Problem Input: n intervals [s(i), f(i)) for 1≤ i ≤ n Output: A schedule S of the n intervals No two intervals in S conflict |S| is maximized
Analyzing the algorithm R: set of requests A* has no conflicts Set A to be the empty set While R is not empty Choose i in R with the earliest finish time A* is an optimal solution Add i to A Remove all requests that conflict with i from R Return A* = A
Greedy “stays ahead” Greedy OPT
What can you say about f(i1) and f(j1)? Greedy “stays ahead” A* = i1,…,ik O = j1,…,jm k = m What do we need to prove? What can you say about f(i1) and f(j1)?
A formal claim For every r ≤ k, f(ir) ≤ f(jr) A* = i1,…,ik O = j1,…,jm The greedy algorithm outputs an optimal A Proof by contradiction: A is not optimal A* = i1,…,ik O = j1,…,jm m > k After ik, R was non-empty! ik No conflict! jk jk+1
Today’s agenda Analyze run-time of the greedy algorithm Prove the claim Analyze run-time of the greedy algorithm
The mid-term mixup Proctors allowed early arrivals to read the exam questions Unfair to students who did not come early Proposal: I’ll add 5 points at the end of the semester if it bumps up a letter grade (but not from A- to A) Email me if you have comments
The mid-term story Average: 50.2 Median: 51 Remember, mid term score gets dropped if you better on the final Time pressure issues
Greedy can always pick jr Proof of claim For every r ≤ k, f(ir) ≤ f(jr) Why is r=1 OK? By induction on r Assume true up to r-1 Greedy can always pick jr ? ir-1 ir jr-1 jr