Lecture 33 CSE 331 Nov 20, 2015. 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.

Slides:



Advertisements
Similar presentations
Lecture 20 CSE 331 Oct 10, HW 5 due today Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm.
Advertisements

9/27/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 14 Dynamic.
Dynamic Programming.
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.
CSCI 256 Data Structures and Algorithm Analysis Lecture 13 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Lecture 30 CSE 331 Nov 13, To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM.
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 28 CSE 331 Nov 9, Flu and HW 6 Graded HW 6 at the END of the lecture If you have the flu, please stay home Contact me BEFORE you miss a.
Lecture 21 CSE 331 Oct 20, Announcements Graded mid-term exams at the END of the lecture Sign up for blog posts/group scribe leader No more than.
Lecture 31 CSE 331 Nov 16, Jeff is out of town this week No regular recitation or Jeff’s normal office hours I’ll hold extra Question sessions Mon,
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 23 CSE 331 Oct 24, Temp letter grades assigned See the blog post for more details.
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 24 CSE 331 Oct 27, Online office hours tonight 9:00pm.
Lecture 20 CSE 331 Oct 21, 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.
Lecture 30 CSE 331 Nov 10, Online Office Hours
9/10/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 13 Dynamic.
Lecture 28 CSE 331 Nov 9, Mini project report due WED.
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
Lecture 38 CSE 331 Dec 5, OHs today (only online 9:30-11)
CSE 331: Review.
Lecture 18 CSE 331 Oct 12, HW 5 due today Q1, Q2 and Q3 in different piles I will not take any HW after 1:15pm.
Lecture 18 CSE 331 Oct 6, Group/Algo registration deadline BOTH DUE WED by 11:59pm!
Lecture 9 CSE 331 June 18, The “real” end of Semester blues MondayTuesdayWednesdayThursdayFriday Project 331 HW Exam study Party! Write up a term.
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 16 CSE 331 Oct 5, 2016.
Lecture 17 CSE 331 Oct 3, 2014.
Lecture 31 CSE 331 Nov 13, 2017.
Lecture 34 CSE 331 Nov 26, 2012.
Lecture 34 CSE 331 Nov 26, 2012.
Lecture 36 CSE 331 Nov 29, 2017.
Lecture 36 CSE 331 Nov 30, 2016.
Lecture 35 CSE 331 Nov 27, 2017.
Lecture 34 CSE 331 Nov 20, 2017.
Lecture 17 CSE 331 Oct 7, 2016.
Lecture 33 CSE 331 Nov 18, 2016.
Lecture 33 CSE 331 Nov 17, 2017.
Lecture 8 CSE 331 Sep 12, 2014.
Lecture 35 CSE 331 Nov 28, 2016.
Lecture 37 CSE 331 Dec 1, 2017.
Lecture 26 CSE 331 Nov 1, 2017.
Lecture 27 CSE 331 Nov 3, 2017.
Richard Anderson Lecture 16a Dynamic Programming
Lecture 16 CSE 331 Oct 4, 2017.
Lecture 37 CSE 331 Nov 30, 2011.
Lecture 18 CSE 331 Oct 12, 2011.
Lecture 19 CSE 331 Oct 8, 2014.
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 18 CSE 331 Oct 9, 2017.
Lecture 36 CSE 331 Nov 28, 2011.
Lecture 36 CSE 331 Nov 30, 2012.
Lecture 37 CSE 331 Dec 2, 2016.
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.
Presentation transcript:

Lecture 33 CSE 331 Nov 20, 2015

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 the table

Related HW stuff HW 9 has been posted on piazza Solutions to HW 8 at the END of the lecture Update on HW pickups by the weekend

High level view of CSE 331 Problem Statement Algorithm Problem Definition “Implementation” Analysis Correctness+Runtime Analysis Data Structures Three general techniques

Greedy Algorithms Natural algorithms Reduced exponential running time to polynomial

Divide and Conquer Recursive algorithmic paradigm Reduced large polynomial time to smaller polynomial time

A new algorithmic technique Dynamic Programming

Dynamic programming vs. Divide & Conquer

Same same because Both design recursive algorithms

Different because Dynamic programming is smarter about solving recursive sub-problems

End of Semester blues MondayTuesdayWednesdayThursdayFriday Project 331 HW Exam study Party! Write up a term paper Can only do one thing at any day: what is the optimal schedule to obtain maximum value? (30) (3) (2) (5) (10)

Previous Greedy algorithm MondayTuesdayWednesdayThursdayFriday Order by end time and pick jobs greedily Project (30) 331 HW (3) Party! (2) Exam study (5) Write up a term paper (10) Greedy value = 5+2+3= 10 OPT = 30

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 the table

Today’s agenda Formal definition of the problem Start designing a recursive algorithm for the problem

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

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

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

How many distinct OPT values?

Using Memory to be smarter Pow (a,n) // n is even and ≥ 2 return Pow(a,n/2) * Pow(a, n/2) O(n) as we recompute! Pow (a,n) // n is even and ≥ 2 return t * t t= Pow(a,n/2) O(log n) as we compute only once

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)

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

Reading Assignment Sec 6.1, 6.2 of [KT]

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