If you must pay an amount in coins, the "intuitive" algorithm is: pay as much as possible with the largest denomination coin, and then go on to pay the rest with the other coins. For example, if there are 25, 5 and 1 cent coins, to pay someone 32 cents, you'd first give him a 25 cents coin, then one 5 cent coin, and finally two 1 cent coins.)
However, this doesn't always end paying with as few coins as possible: if we had 25, 10 and 1 cent coins, paying 32 cents with the "intuitive" algorithm would use 8 coins, while three 10 cent coins and two 1 cent coins would be better.
We can call a set "intuitive", if the "intuitive algorithm" always pays out any amount with as few coins as possible.
The problem: give an algorithm that allows you to decide that {25,5,1} is an "intuitive" set, while {25,10,1} isn't.
(In reply to
quick thought by Larry)
For any function f(x), I can come up with an intuitive set that is higher than f(x) at x=2. Namely, that intuitive set would be {1,round(f(2))+1}. This is an intuitive set, since {1,n} is an intuitive set for any n.
Also, standard US currency beginning with pennies is an intuitive set, even though it doesn't follow the "always multiples" (e.g. a quarter is not a multiple of a dime).
P.S. I had always heard this algorithm called the "Greedy Algorithm"
Edited on March 30, 2005, 1:21 pm
|
Posted by Avin
on 2005-03-30 13:19:37 |