Download presentation
Presentation is loading. Please wait.
1
Lecture 22 CSE 331 Oct 22, 2010
2
A non-CSE 331 poll Vs. iphone Andriod
3
Announcements Graded HW 5 next week HW 6 has been posted
Jeff will be out of town starting next week See the blog for more details
4
Mid Term stuff Mid term post up on the blog
Read it before asking for regrade requests A temp grade assigned by early next week I’ll ask some of you to meet me in person
5
Student blog posts on new blog
6
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
7
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
8
Today’s agenda Analyze run-time of the greedy algorithm
Prove correctness of the greedy algorithm Analyze run-time of the greedy algorithm
9
Greedy “stays ahead” Greedy OPT
10
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)?
11
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
12
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.