Lecture16 - Dynamic Programming CSE 421 Algorithms Richard Anderson Lecture 16 Dynamic Programming Weighted Interval Scheduling Given a collection

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSE 421 Algorithms Richard Anderson Lecture 16 Dynamic Programming Dynamic Programming • Weighted Interval Scheduling • Given a collection of intervals I 1 ,…,I n with weights w 1 ,…,w n , choose a maximum weight set of non-overlapping intervals 4 6 3 5 7 6 Optimality Condition • Opt[ j ] is the maximum weight independent set of intervals I 1 , I 2 , . . ., I j • Opt[ j ] = max( Opt[ j – 1], w j + Opt[ p[ j ] ]) – Where p[ j ] is the index of the last interval which finishes before I j starts Algorithm MaxValue(j) = if j = 0 return 0 else return max( MaxValue(j-1), w j + MaxValue(p[ j ])) Worst case run time: 2 n A better algorithm M[ j ] initialized to -1 before the first recursive call for all j MaxValue(j) = if j = 0 return 0; else if M[ j ] != -1 return M[ j ]; else M[ j ] = max(MaxValue(j-1), w j + MaxValue(p[ j ])); return M[ j ]; Iterative Algorithm Express the MaxValue algorithm as an iterative algorithm MaxValue { }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Fill in the array with the Opt values Opt[ j ] = max (Opt[ j – 1], w
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/25/2012 for the course CSE 421 taught by Professor Richardanderson during the Fall '06 term at University of Washington.

Page1 / 4

Lecture16 - Dynamic Programming CSE 421 Algorithms Richard Anderson Lecture 16 Dynamic Programming Weighted Interval Scheduling Given a collection

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online