How to tell if greedy algorithm suffices for finding minimum coin change?

后端 未结 3 1948
闹比i
闹比i 2020-12-16 04:26

The minimum coin change problem is an NP-complete problem but for certain sets of coins the greedy algorithm (choose largest denominations first) works. Given a set of integ

3条回答
  •  無奈伤痛
    2020-12-16 05:08

    I recently came up with 1 solution that seemed to show if the given 2 conditions are satisfied, the greedy algorithm would yield the optimal solution.

    a) The G.C.D (All the denominations except 1) = 2nd Smallest denomination.

    b) The sum of any 2 consecutive denominations must be lesser than the 3rd consecutive denomination.

    For eg. c2 + c3 < c4.

    (Where c1 = 1; c2, c3, c4 are coin denominations in ascending order).

    I understand this is not a complete solution. However, I believe that if these 2 conditions are met, the greedy algorithm will yield the optimal solution.

提交回复
热议问题