There are drawbacks to simply giving out the largest coins.
Suppose your vending machine is located outside each coin, with the exception of twenty of each of the coins 50c, 20c and 1c, and you need to deliver 60c per shift.
The โbiggest priorityโ (or greedy) scheme will give you eleven coins, one 50 c coin and ten 1c coins.
The best solution is three 20c coins.
Greedy schemes give only local optimal solutions. For global optima, as a rule, you need to study all the possibilities (although there may be minimax-type algorithms to reduce the search space) to be sure that for delivery of changes it is usually within computability limits.
source share