This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 2 3 4 5 8 9 11 12 9 Output sequence of A’s, B’s to minimize cost, subject to constraint that B’s are in blocks of 4 Cost of A = r* ∑ demands served by A Cost of B = 4C*number of blocks of size 4 (1) What was the last decision? A vs. B in period n (2) What would you need to know, to decide correctly? Pick B: Cost will be 4C + OPT[n4] Pick A: will cost r*S n + OPT[n1] (3) Design an algorithm to Fll in the DPT using (nested) loop(s). Initialize OPT(i) = ∞ for i < 0, OPT(i) = 0 for i = 0. for i = 1, 2, . .., n OPT(i) = min{4C + OPT(i  4), r*S i + OPT(i1)} endfor Chapter 6, Problem 5 Compare to interval scheduling (1) (2) payo f of breaking between i, i+1 is quality(string(i+1:n)) + OPT(string(1:i)) 1dimensional DPT; ith entry is OPT(string(1:i)) 162 OPT(0) = 0 for i = 1, . .., n OPT(i) = max (0 <= j < i); {q(j+1:i) + OPT(j) } endfor O(n 2 ) 163...
View
Full
Document
This note was uploaded on 10/02/2008 for the course CS 482 taught by Professor Kleinberg during the Spring '08 term at Cornell.
 Spring '08
 KLEINBERG
 Algorithms, C Programming

Click to edit the document details