Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 37 CSE 331 Nov 4, 2009. Homework stuff (Last!) HW 10 at the end of the lecture Solutions to HW 9 on Monday Graded HW 9 on.

Similar presentations


Presentation on theme: "Lecture 37 CSE 331 Nov 4, 2009. Homework stuff (Last!) HW 10 at the end of the lecture Solutions to HW 9 on Monday Graded HW 9 on."— Presentation transcript:

1 Lecture 37 CSE 331 Nov 4, 2009

2 Homework stuff http://xkcd.com/336/ (Last!) HW 10 at the end of the lecture Solutions to HW 9 on Monday Graded HW 9 on Wednesday

3 Weighted Interval Scheduling Input: n jobs (s i,t i,v i ) Output: A schedule S s.t. no two jobs in S have a conflict Goal: max Σ j in S v j Assume: jobs are sorted by their finish time

4 Property of OPT OPT(j) = max { v j + OPT( p(j) ), OPT(j-1) }

5 A recursive algorithm M-Compute-Opt(j) If j = 0 then return 0 M[j] = max { v j + M-Compute-Opt( p(j) ), M-Compute-Opt( j-1 ) } If M[j] is not null then return M[j] return M[j] M-Compute-Opt(j) = OPT(j) Run time = O(# recursive calls)

6

7 Bounding # recursions M-Compute-Opt(j) If j = 0 then return 0 M[j] = max { v j + M-Compute-Opt( p(j) ), M-Compute-Opt( j-1 ) } If M[j] is not null then return M[j] return M[j] Whenever a recursive call is made an M value of assigned At most n values of M can be assigned O(n) overall

8 Recursion+ memory = Iteration Iteratively compute the OPT(j) values M[0] = 0 M[j] = max { v j + M[p(j)], M[j-1] } For j=1,…,n Iterative-Compute-Opt M[j] = OPT(j) O(n) run time

9 Reading Assignment Sec 6.1, 6.2 of [KT]


Download ppt "Lecture 37 CSE 331 Nov 4, 2009. Homework stuff (Last!) HW 10 at the end of the lecture Solutions to HW 9 on Monday Graded HW 9 on."

Similar presentations


Ads by Google