1
$\begingroup$

You find yourself in a country with integer coin denominations $c_1 < c_2 < ... < c_r$, where $c_1 = 1$. Unfortunately, the greedy algorithm is not guaranteed to find the optimal way to make change. Let $C(i)$ be the minimum number of coins needed to make change for $i$ cents.

(a) Find a recurrence for $C$.

(b) Write an algorithm for computing an array OPT$[0...n]$ where OPT$[i]$$ = C(i)$.

I'm not really sure how to go about doing this. What does the information about the greedy algorithm tell us about the behavior of the problem? How can we use the information given to write a recurrence for $C(i)$?

  • 2
    The information about the greedy algorithm basically just tells you how *not* to approach the problem.2012-12-17

3 Answers 3