Computer Science 170 - Fall 1997 - Papadimitriou - Midterm 2

# Computer Science 170 - Fall 1997 - Papadimitriou - Midterm...

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

CS 170, Midterm #2, Fall 1997 CS 170, Fall 1997 Second Midterm Professor Papadimitriou Problem #1 (10 Points) Remember the change-maker problem : We are given k integers d 1 , . .., d k > 0 (the coin denominations ) and an integer n . We want to write n as the sum of denominations, with repetitions, with as few coins as possible. For example, for denominations 1, 5, 10, and 25, and n = 83, then the optimum solution is 25 + 25 + 25 + 5 + 1 + 1 + 1, with cost 7. Give a dynamic programming algorithm for the change-maker problem. Suppose that c( i ) is the minimum number of coins adding up to i >= 0. A. Dynamic programming recurrence: Basis (value at zero): B. Justification of correctness: C. Running time of the corresponding algorithm, as a function of n and k (you don't have to describe the algorithm). Justification of the running time. file:///C|/Documents%20and%20Settings/Jason%20Rafte. ..20Fall%201997%20-%20Papadimitriou%20-%20Mid%202.htm (1 of 6)1/27/2007 5:32:59 PM

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

View Full Document
CS 170, Midterm #2, Fall 1997 D. Is this a polynomial-time algorithm? Why or why not? Problem #2 (10 Points) (a) Write the change-maker problem (see the previous problem) as an integer linear programming problem: choose your variables: minimize this linear function: subject to these constraints: plus, all variables should be integers.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/17/2009 for the course CS 170 taught by Professor Henzinger during the Spring '02 term at Berkeley.

### Page1 / 6

Computer Science 170 - Fall 1997 - Papadimitriou - Midterm...

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

View Full Document
Ask a homework question - tutors are online