Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 20 CSE 331 Oct 21, 2009. Algorithm for Interval Scheduling R: set of requests Set A to be the empty set While R is not empty Choose i in R with.

Similar presentations


Presentation on theme: "Lecture 20 CSE 331 Oct 21, 2009. Algorithm for Interval Scheduling R: set of requests Set A to be the empty set While R is not empty Choose i in R with."— Presentation transcript:

1 Lecture 20 CSE 331 Oct 21, 2009

2 Algorithm for Interval Scheduling R: set of requests Set A to be the empty set While R is not empty Choose i in R with the earliest finish time Add i to A Remove all requests that conflict with i from R Return A A is optimal

3 Run time analysis Set A to be the empty set While R is not empty Choose i in R with the earliest finish time Add i to A Remove all requests that conflict with i from R Return A O(n log n) time sort intervals such that f(i) ≤ f(i+1) O(n) time build array s[1..n] s.t. s[i] = start time for i

4 Today’s agenda Finish run time analysis A more realistic scheduling problem for end of semester blues

5 Run time analysis Set A to be the empty set While R is not empty Choose i in R with the earliest finish time Add i to A Remove all requests that conflict with i from R Return A O(n log n) time sort intervals such that f(i) ≤ f(i+1) O(n) time build array s[1..n] s.t. s[i] = start time for i Do the removal on the fly

6 Algorithm implementation Go through the intervals in order of their finish time 1 1 2 2 3 3 4 4 How can you tell in O(1) time if any of 2,3 or 4 conflict with 1? Check if s[i] < f(1) In general, if jth interval is the last one chosen Pick smallest i>j such that s[i] ≥ f(j) O(n log n) run time

7 Reading Assignment Sec 4.1of [KT]

8 The “real” end of Semester blues MondayTuesdayWednesdayThursdayFriday Project 331 HW Exam study Party! Write up a term paper There are deadlines and durations of tasks

9 The “real” end of Semester blues MondayTuesdayWednesdayThursdayFriday Project 331 HW Exam study Party! Write up a term paper There are deadlines and durations of tasks

10 The algorithmic task MondayTuesdayWednesdayThursdayFriday Project 331 HW Exam study Party! Write up a term paper YOU decide when to start each task You have to do ALL the tasks

11 Scheduling to minimize lateness MondayTuesdayWednesdayThursdayFriday Project 331 HW Exam study Party! Write up a term paper All the tasks have to be scheduled GOAL: minimize maximum lateness All the tasks have to be scheduled GOAL: minimize maximum lateness

12 One possible schedule MondayTuesdayWednesdayThursdayFriday 331 HW Exam study Party! Write up a term paper All the tasks have to be scheduled GOAL: minimize maximum lateness All the tasks have to be scheduled GOAL: minimize maximum lateness Lateness = 0 Lateness = 2


Download ppt "Lecture 20 CSE 331 Oct 21, 2009. Algorithm for Interval Scheduling R: set of requests Set A to be the empty set While R is not empty Choose i in R with."

Similar presentations


Ads by Google