packbat: A bat wearing a big asexual-flag (black-gray-white-purple) backpack. (Default)
packbat ([personal profile] packbat) wrote2007-07-25 02:32 pm
Entry tags:

[identity profile] active-apathy.livejournal.com 2007-07-26 02:44 am (UTC)(link)
*nodnods* It is. It's a fairly trivial example, but it is nonetheless.

[identity profile] roaminrob.livejournal.com 2007-07-27 04:41 pm (UTC)(link)
How?

Change-making -- in the U.S. at least -- is trivial because the greedy approximation algorithm works perfectly every time. That particular algorithm works perfectly every time because there isn't the kind of overlap in units of money that you would find in, say, a geometric packing problem.

F'rinstance, for any amount of change to be dispensed, you start with quarters. Add quarters until you can't add any more. Next add dimes. Then nickels. Finish it off with pennies.

That can be done in linear time, because it requires no back-tracking, or recursion.