08 - Review of dynamic programming

08 - Review of dynamic programming - 2 3 4 5 8 9 11 12 9...

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

View Full Document Right Arrow Icon
2/20/08 - Review of dynamic programm. .. Chapter 6, Problems 4, 5, 11 Prelim tomorrow 7:30-9, Upson B17 Chapter 1, 4, 5, 6 Design techniques Greedy, Divide and Conquer, Dynamic Programming Key algorithms Gale-Shapley, Kruskal, Prim, Bellman-Ford Key structures: MST, Stable Matching GREEDY Stays ahead Correctness: induct on t. other SOLN, the t th stage of GREEDY is at least as good as t th stage of SOLN. “stage”? “at least as good”? problem-dependent Exchange De±ne property P (problem-dependent) (1) Every OPT has property P. (2) GREEDY has property P. (3) All solutions with property P are equally good. Divide and Conquer (1) How to partition the input? Arbitrary Using some ordering property 16-1 16
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) How to merge the sub-solutions? (3) Running time: Solve a recurrence. f(2n) = 3f(n) + O(n) - Karatsuba f(2n) = 2f(n) + O(1) f(n/2) + O(n) Correctness: Induction on problem size. Chapter 6, Problem 11 Given sequence of demands i = 1
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the 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[n-4] Pick A: will cost r*S n + OPT[n-1] (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(i-1)} 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)) 1-dimensional DPT; ith entry is OPT(string(1:i)) 16-2 OPT(0) = 0 for i = 1, . .., n OPT(i) = max (0 <= j < i); {q(j+1:i) + OPT(j) } endfor O(n 2 ) 16-3...
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.

Page1 / 3

08 - Review of dynamic programming - 2 3 4 5 8 9 11 12 9...

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