Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 19 CSE 331 Oct 14, 2011.

Similar presentations


Presentation on theme: "Lecture 19 CSE 331 Oct 14, 2011."— Presentation transcript:

1 Lecture 19 CSE 331 Oct 14, 2011

2 Announcements Graded HW 4 next Th onwards HW 5 has been posted

3 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

4 Sign up for scribe/blog post

5 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

6 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

7 Greedy “stays ahead” Greedy OPT

8 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)?

9 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

10 Today’s agenda Analyze run-time of the greedy algorithm
Prove the claim Analyze run-time of the greedy algorithm

11 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) me if you have comments

12 The mid-term story Average: 50.2 Median: 51
Remember, mid term score gets dropped if you better on the final Time pressure issues

13 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


Download ppt "Lecture 19 CSE 331 Oct 14, 2011."

Similar presentations


Ads by Google