简体   繁体   中英

Greedy algorithm and coins algorithm

First, yes it's my HW and I find it hard so I'll really appreciate some guidance.

I need to prove that for denomination of 1,x,x 2 ...x n when x>=1 the greedy algorithm for the coins problem always work .

  • We will always get the amount of money we need in minimal coins number when we always pick the maximal coin that smaller from the amount.

Thank you.

As this is your homework I will not provide a complete answer but will rather try to guide you:

First as it usually happens for problems of that type try and prove for yourself that the statement is true for the first few natural numbers. Try to summarize what you use to make the proof for them. This usually will give you some guidance of the correct approach.

I would use induction for this one.

Another option that might help you - represent all the numbers in numerical system with base x . This should make it clearer why the statement is true.

Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM