

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


ECS122A Handout Money Changing
∑^ n i=
aixi
.
∑n i=1 aixi^ for some nonnegative integers^ a^1 ,^ · · ·^ , an. Conversely, in order to express A = 1 as a linear combination, you must have xi = 1 for some i.
∑n i=1 aixi^ is that^ g^ =^ gcd(x^1 , ..., xn) divides^ A. In fact,^ g|A^ turns out to be both necessary and sufficient for A ≥ X for some (large) X. Here is a proof. From the extended Euclidean algorithm we know we can write g =
∑n i=1 gixi^ with some possibly negative gi. Now let G =
∑n i=1 |gi|xi,^ xmin^ = mini^ xi,^ k^ =^ xmin/g, and^ X^ =^ kG. First note that the k consecutive multiples of g in the set S = {kG, kG + g, kG + 2 g,... , kG + (k − 1)g} all have nonnegative coefficients when written as
∑n i=1 aixi. The next multiple of g is kG+kg = kG+xmin, which has even larger nonnegative coefficients than kG. The next k − 1 multiples of g consequently also have nonnegative coefficients until we get to kG + 2xmin, and so on. Note that the coefficients are not necessarily unique (all the xi could be identical), but we have shown that there is at least one set of nonnegative coefficients for all multiple of g at least equal to X.
∑n i=1 aixi, and such that the sum of all^ ai’s is minimal —that is, you use the smallest possible number of coins. Here is a greedy algorithm for solving this problem: Order your denominations such that x 1 > x 2 > · · · > xn. Then the greedy algorithm for this problem would be: Given A, let a 1 be the largest integer such that a 1 x 1 ≤ A. If A − a 1 x 1 > 0, let a 2 be the largest integer such that a 2 x 2 ≤ A − a 1 x 1. If you have nothing left over after doing this for i = 1, · · · , n, then A =
∑n i=1 aixi.
∑ 4 i=1 aixi^ =^
∑ 4 i=1 bixi^ and^
∑ 4 i=1 ai^ >^
∑ 4 i=1 bi, where the^ ai^ were determined by the greedy algorithm and the bi are optimal in that
∑ 4 i=1 bi^ is minimal. W.l.o.g.^ a^4 =^ b^4 [since a 4 ≤ 4 any change of the number of 1 cent coins must occur in 5 unit steps to give the same sum-this is obviously worse than changing b 3 ], in addition to that note that a 3 ≤ 1. By the above considerations we must have a 1 > b 1. Let x := a 1 −b 1. We have three cases to consider: a 2 = b 2 , a 2 > b 2 and a 2 < b 2. If we set y := a 2 − b 2 then we can compute b 3 = 5x + 2y + a 3. Thus the number of coins changes by
∑ 4 i=1 bi^ −^
∑ 4 i=1 ai^ = 4x^ +^ y. If we can show that this number is positive, this is a contradiction and we are done. In cases 1 and 2, x and y are ≥ 0. Therefore 4x + y is clearly positive. In case 3, y is negative. But, as we have to ensure that b 3 = 5x + 2y + a 3 is ≥ 0 and we know that a 3 is at most 1, we have y ≥ −^52 x − 12. Hence 4x + y ≥ 32 x − 12 and it is again positive.
(a) M. J. Magazine, G. L. Nemhauser, L. E. Trotter Jr., When the Greedy Solution Solves a Class of Knapsack Problems, Operations Research 23 (1975), p. 207 – 217 (b) John Dewey Jones, Orderly Currencies, American Mathematical Monthly 101 (1994), p. 36 – 38 (c) Stephen B. Maurer, Disorderly Currencies, American Mathematical Monthly 101 (1994), p. 419.