lecture 23 cse 331 oct 24, 2010. temp letter grades assigned see the blog post for more details

16
Lecture 23 CSE 331 Oct 24, 2010

Post on 21-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Lecture 23

CSE 331Oct 24, 2010

Temp letter grades assigned

See the blog post for more details

Emails have been sent out

If you got an email, please schedule your appointment with me ASAP

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 AA is optimalA is optimal

An observation

In a valid schedule sorted by finish time is the same as sorted by start time

331 HW331 HWExam studyExam study

Party!Party!

A naïve 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) timeO(n) time

O(n) timeO(n) time

At most n iterationsAt most n iterationsO(n2) timeO(n2) time

Today’s agenda

Better run time analysis (on slides)

A more realistic scheduling problem for end of semester blues

Questions?

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 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 iO(n) time build array s[1..n] s.t. s[i] = start time for i

Do the removal on

the fly

Do the removal on

the fly

Algorithm implementation

Go through the intervals in order of their finish time

11

22

33

44

How can you tell in O(1) time if any of 2,3 or 4 conflict

with 1?

How can you tell in O(1) time if any of 2,3 or 4 conflict

with 1?

Check if s[i] < f(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

timeO(n log n) run

time

Reading AssignmentSec 4.1of [KT]

The “real” end of Semester blues

Monday Tuesday Wednesday Thursday Friday

ProjectProject

331 HW331 HWExam studyExam study

Party!Party!

Write up a term paperWrite up a term paper

There are deadlines and durations of tasks

There are deadlines and durations of tasks

The “real” end of Semester blues

Monday Tuesday Wednesday Thursday Friday

ProjectProject

331 HW331 HW

Exam studyExam study

Party!Party!

Write up a term paperWrite up a term paper

There are deadlines and durations of tasks

There are deadlines and durations of tasks

The algorithmic task

Monday Tuesday Wednesday Thursday Friday

ProjectProject

331 HW331 HW

Exam studyExam study

Party!Party!

Write up a term paperWrite up a term paper

YOU decide when to start each task

YOU decide when to start each task

You have to do ALL the tasks

You have to do ALL the tasks

Scheduling to minimize lateness

Monday Tuesday Wednesday Thursday Friday

ProjectProject

331 HW331 HW

Exam studyExam study

Party!Party!

Write up a term paperWrite up a term paper

All the tasks have to be scheduledGOAL: minimize maximum latenessAll the tasks have to be scheduled

GOAL: minimize maximum lateness

One possible schedule

Monday Tuesday Wednesday Thursday Friday

331 HW331 HW Exam studyExam studyParty!Party! Write up a term paperWrite up a term paper

All the tasks have to be scheduledGOAL: minimize maximum latenessAll the tasks have to be scheduled

GOAL: minimize maximum lateness

Lateness = 0Lateness = 0 Lateness = 2Lateness = 2