Find minimum number of coins with Largest value coins?

316 Views Asked by At

There is a greedy algorithm for coin change problem : using most valuable coin as possible. How We can find a quick method to see which of following sets of coin values this algoithms cannot find optimal solutions (i.e the minimum number of coins). We assume that we have infinitely many coins of each type.

Examples: $\{1, 4, 7\}$, $\{1, 2, 5\}$, $\{1, 7, 10\}$, $\{1, 5, 10\}$

Why just the third set is not optimal and other sets is optimal?

I see one paper on Link but not familiar with me.

1

There are 1 best solutions below

5
On

Theorem 4 in the OP's linked-to paper says that a set $\{1,c_2,c_3\}$ with $1\lt c_2\lt c_3$ is "non-canonical" (meaning the greedy algorithm is sub-optimal) if and only if $0\lt r\lt c_2-q$, where $c_3=qc_2+r$ with $0\le r\lt c_2$.

Thus $\{1,7,10\}$ is non-canonical because $q=1$ and $r=3$ (i.e., $10=1\cdot7+3$) and $0\lt3\lt7-1$.

On the other hand, $\{1,4,7\}$ is canonical because $7=1\cdot4+3$ implies $q=1$ and $r=3$ and the condition $0\lt r\lt c_2-q$ does not hold since $3$ is not less than $4-1$.

The other two sets can be handled similarly. It's just a matter of working out the $q$ and $r$ for each set and checking that either $0=r$ or $r=c_2-q$.