This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: attend: Amazon press release Thu 26 Steve Jobs memorial Wed 37 Nvidia open house Thurs 14 You want to attend as many of these as possible, but they overlap so you cant attend them all b. Interval scheduling Given: a collection of n intervals [s1, e1], [s2, e2], , [sn, en] Find the maximum # of intervals that are disjoint c. A greedy algorithm builds up a solution piece by piece, always picking the piece that looks best at the moment d. Idea 1: always pick the interval which is valid and has the earliest starting time (BAD) Idea 2: pick the shortest event (BAD) Idea 3: pick the event with the earliest finish time (this works) e. Code: Sort intervals by ending time, so that e1 <= e2 <= <= en T = inf busy up to time T) For I = 1 to n: If si >T: Pick event [wi, ei] T = ei O(n log n) to sort. f....
View Full
Document
 Spring '08
 staff
 Algorithms

Click to edit the document details