0

We are given a number of coins and a bill and want to exchange the bill into coins. We are asked to find the distinct number of ways of different combinations of coins that make up the bill.

The recursive solution I see everywhere is the following: Let $F(n, c)$ be the total number of ways to make change for amount $= n$ with $m$ coins $= \{c_1,...c_m\}$. Take the last coin $c_m$. We have two cases:

(1) We used $c_m$ in the solution and so we compute $F(n)=F(n-c_m,coins)$.

(2) We didn't use the coin $c_m$ in the solution and so we compute $F(n,coins-c_m)$.

Therefore, $$F(n) = F(n-c_m,coins) + F(n,coins-c_m)$$

I also see another way of solving this problem (here)) which basically is summarized as follows:

(1) start with $c_1$, then compute $F(n-c_1, \{c_1\})$.

(2) start with $c_2$, then compute $F(n-c_2, \{c_1,c_2\})$.

...

(m) start with $c_m$, then compute $F(n-c_m, \{c_1,c_2,...,c_m\})$.

The final sum is: $$F(n, coins) = F(n-c_1,\{c_1\}) + F(n-c_2,\{c_1,c_2\}) + ... + F(n-c_m, \{c_1,c_2,...,c_m\})$$

I see explanations and pictures of recursion trees showing how each method generates all the combinations we're interested in but I don't see how we could for example formally prove method 1? Where is this counting principle from? Is there a chapter or an article that I can read to understand it? Is there a way to prove formally that the number of ways to make change is $F(n) = F(n-c_m,coins) + F(n,coins-c_m)$?

nemo
  • 63
  • It's very unclear what you want from such a "formal proof". This is really nothing more than the fact that the cardinality of the union of two disjoint sets is the sum of their cardinalities (which is sometimes taken as the definition of addition). You could write out the bijections more formally in set-theoretic language but I doubt you would find this enlightening. – Eric Wofsey May 13 '20 at 04:02
  • you are right, maybe I'm complicating things. In the past (class), whenever we presented a dynamic programming algorithm (which is always based on some recurrence), we had to provide some proof of the recurrence (example: https://web.stanford.edu/class/archive/cs/cs161/cs161.1138/lectures/16/Small16.pdf). What did you mean by writing them out more formally using set theory? thanks – nemo May 13 '20 at 04:18

0 Answers0