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 2-6 Steve Jobs memorial Wed 3-7 Nvidia open house Thurs 1-4 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