Lecture 36 CSE 331 Nov 30, 2012.

Slides:



Advertisements
Similar presentations
Lecture 30 CSE 331 Nov 8, HW 7 due today Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm DO NOT FORGET TO WRITE DOWN YOUR.
Advertisements

Lecture 38 CSE 331 Dec 7, The last few days Today: Solutions to HW 9 (end of lecture) Wednesday: Graded HW 9 (?), Sample final, Blog post on the.
Lecture 37 CSE 331 Nov 4, Homework stuff (Last!) HW 10 at the end of the lecture Solutions to HW 9 on Monday Graded HW 9 on.
Lecture 38 CSE 331 Dec 3, A new grading proposal Towards your final score in the course MAX ( mid-term as 25%+ finals as 40%, finals as 65%) .
Lecture 39 CSE 331 Dec 6, On Friday, Dec 10 hours-a-thon Atri: 2:00-3:30 (Bell 123) Jeff: 4:00-5:00 (Bell 224) Alex: 5:00-6:30 (Bell 242)
Lecture 36 CSE 331 Dec 2, Graded HW 8 END of the lecture.
Lecture 34 CSE 331 Nov 30, Graded HW 8 On Wednesday.
Lecture 37 CSE 331 Dec 1, A new grading proposal Towards your final score in the course MAX ( mid-term as 25%+ finals as 40%, finals as 65%) .
Lecture 39 CSE 331 Dec 9, Announcements Please fill in the online feedback form Sample final has been posted Graded HW 9 on Friday.
Lecture 30 CSE 331 Nov 10, Online Office Hours
Lecture 38 CSE 331 Dec 2, Review Sessions etc. Atri: (at least ½ of) class next Friday Jiun-Jie: Extra office hour next Friday Jesse: Review Session.
Lecture 38 CSE 331 Dec 5, OHs today (only online 9:30-11)
CSE 331: Review.
Lecture 33 CSE 331 Nov 20, HW 8 due today Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm Submit your HWs to the side of.
CSE 331: Review August 1, Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical.
Lecture 32 CSE 331 Nov 16, 2016.
Lecture 31 CSE 331 Nov 14, 2016.
Lecture 26 CSE 331 Nov 2, 2016.
Lecture 23 CSE 331 Oct 26, 2016.
Lecture 17 CSE 331 Oct 3, 2014.
Lecture 31 CSE 331 Nov 13, 2017.
Lecture 34 CSE 331 Nov 26, 2012.
Lecture 22 CSE 331 Oct 22, 2010.
Lecture 34 CSE 331 Nov 26, 2012.
Lecture 21 CSE 331 Oct 21, 2016.
Lecture 36 CSE 331 Nov 29, 2017.
Lecture 21 CSE 331 Oct 20, 2017.
Lecture 36 CSE 331 Nov 30, 2016.
Lecture 35 CSE 331 Nov 27, 2017.
Lecture 34 CSE 331 Nov 20, 2017.
Lecture 33 CSE 331 Nov 18, 2016.
Lecture 33 CSE 331 Nov 17, 2017.
Lecture 35 CSE 331 Nov 28, 2016.
Lecture 37 CSE 331 Dec 1, 2017.
Lecture 24 CSE 331 Oct 25, 2013.
Lecture 26 CSE 331 Nov 1, 2017.
Lecture 27 CSE 331 Nov 3, 2017.
Lecture 23 CSE 331 Oct 25, 2017.
Lecture 23 CSE 331 Oct 24, 2011.
Lecture 19 CSE 331 Oct 12, 2016.
Lecture 26 CSE 331 Nov 2, 2012.
Richard Anderson Lecture 16a Dynamic Programming
Lecture 32 CSE 331 Nov 14, 2011.
Lecture 37 CSE 331 Nov 30, 2011.
Dynamic Programming Longest Path in a DAG, Yin Tat Lee
Lecture 19 CSE 331 Oct 8, 2014.
Lecture 20 CSE 331 Oct 17, 2011.
Lecture 32 CSE 331 Nov 15, 2017.
Lecture 33 CSE 331 Nov 14, 2014.
Lecture 27 CSE 331 Oct 31, 2014.
Lecture 33 CSE 331 Nov 15, 2013.
Lecture 34 CSE 331 Nov 18, 2011.
Lecture 34 CSE 331 Nov 21, 2016.
Lecture 28 CSE 331 Nov 7, 2012.
Lecture 27 CSE 331 Nov 2, 2010.
Lecture 22 CSE 331 Oct 15, 2014.
Lecture 18 CSE 331 Oct 9, 2017.
Lecture 19 CSE 331 Oct 14, 2011.
Lecture 24 CSE 331 Oct 24, 2014.
Lecture 36 CSE 331 Nov 28, 2011.
Lecture 37 CSE 331 Dec 2, 2016.
Lecture 23 CSE 331 Oct 24, 2011.
Lecture 31 CSE 331 Nov 11, 2011.
Lecture 25 CSE 331 Oct 28, 2011.
Lecture 19 CSE 331 Oct 10, 2016.
Lecture 32 CSE 331 Nov 12, 2014.
Lecture 27 CSE 331 Nov 4, 2016.
Lecture 27 CSE 331 Nov 1, 2013.
Lecture 36 CSE 331 Nov 22, 2013.
Lecture 37 CSE 331 Dec 3, 2018.
Presentation transcript:

Lecture 36 CSE 331 Nov 30, 2012

HW 9 due today I will not take any HW after 1:15pm Q1, Q 2 and Q 3 in separate piles I will not take any HW after 1:15pm

Other HW related stuff Solutions to HW 9 at the end of the lecture HW 8 should be available for pickup from Monday HW 10 has been posted on the blog (Due in last lecture)

Sample final exam Posted on blog/piazza Final exam from last year Can submit Q1 and Q2 as Q4 on HW 10 next Friday

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

Couple more definitions p(j) = largest i<j s.t. i does not conflict with j p(j) < j = 0 if no such i exists OPT(j) = optimal value on instance 1,..,j

HW 9 due today I will not take any HW after 1:15pm Q1, Q 2 and Q 3 in separate piles I will not take any HW after 1:15pm

Property of OPT OPT(j) = max { vj + OPT( p(j) ), OPT(j-1) } j not in OPT(j) j in OPT(j) OPT(j) = max { vj + OPT( p(j) ), OPT(j-1) } Given OPT(1),…., OPT(j-1), how can one figure out if j in optimal solution or not?

Proof of correctness by induction on j A recursive algorithm Proof of correctness by induction on j Correct for j=0 Compute-Opt(j) If j = 0 then return 0 return max { vj + Compute-Opt( p(j) ), Compute-Opt( j-1 ) } = OPT( p(j) ) = OPT( j-1 ) OPT(j) = max { vj + OPT( p(j) ), OPT(j-1) }

Exponential Running Time 1 2 3 4 5 p(j) = j-2 Only 5 OPT values! OPT(5) OPT(3) OPT(4) Formal proof: Ex. OPT(2) OPT(3) OPT(1) OPT(2) OPT(1) OPT(2) OPT(1)

How many distinct OPT values?

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

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

Property of OPT Given OPT(1), …, OPT(j-1), one can compute OPT(j) OPT(j) = max { vj + OPT( p(j) ), OPT(j-1) } Given OPT(1), …, OPT(j-1), one can compute OPT(j)

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

Reading Assignment Sec 6.1, 6.2 of [KT]

When to use Dynamic Programming There are polynomially many sub-problems Richard Bellman Optimal solution can be computed from solutions to sub-problems There is an ordering among sub-problem that allows for iterative solution

Shortest Path Problem Input: (Directed) Graph G=(V,E) and for every edge e has a cost ce (can be <0) t in V Output: Shortest path from every s to t Assume that G has no negative cycle 1 100 -1000 899 s t Shortest path has cost negative infinity

Rest of today’s agenda Dynamic Program for shortest path

May the Bellman force be with you