complete solution: int change(stack<int> denominations, int total){
int coin = denominations.pop(); int reminder = total % coin; if(reminder == total) return 0; // in case you dont have a perfect change int numberOfCoins = (total-reminder)/coin; if(reminder == 0) return numberOfCoins; else return numberOfCoins + change(denominations, reminder); } On Oct 6, 11:01 am, ligerdave <david.c...@gmail.com> wrote: > use mod recursively. > > total money(or reminder) mod denomination(big > small) > > On Oct 5, 7:13 pm, pre lak <pre.la...@gmail.com> wrote: > > > > > Hi all, > > > Pls help me with the solution to the following problem related to the coin > > changing problem. > > > suppose that the available coins a ein the denominations c^0, c^1 , c^2... > > c^k for some intgers c>1 and k>=1. show tht the greedy algorithm always > > yeilds an optimal solution > > > thanks in advance > > Preethi -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.