0

The Min-Coin Change problem is well-studied (an explanation can be found here: http://www.algorithmist.com/index.php/Min-Coin_Change), but I am interested in solving a variation on it:

For a set of values V, determine a minimal set of coins C such that each of the values in V can be obtained as a sum of coins in C, where each coin in the set may only be used at most once. By minimal we mean the least number of coins.

For example, if V = {3, 8, 9, 10, 11} then it's easy to see that C = {1, 2, 8} because 1 + 2 = 3, 8 = 8, 9 = 1 + 8, 10 = 2 + 8 and 11 = 1 + 2 + 8. There is no smaller set C' that also covers all of these amounts.

So far I cannot think of any better working method than brute forcing subsets, which is obviously not going to work for large V. I'm looking for someone to either show me a better solution or point me in the direction of related problems.

EDIT: Note that there might be multiple minimal sets, I'm interested in finding just one of them.

Filburt
  • 17,626
  • 12
  • 64
  • 115
Arthelais
  • 606
  • 1
  • 7
  • 17

1 Answers1

1

Just a very partial solution/comment :

If your set V has size N, then you need at least ceil[log_2(N)] elements in C. Indeed, the numbers of values you can generate with a set of m elements is at most 2^m and so you must have 2^|C| >= N.

If the total number of bits (in the binary representation of the numbers) that are set to one in at least but not all numbers of V is equal to n, then you need at most n elements in C. Moreover, you get a set C of this size by letting C = {2^{x_1}*r, .., 2^{x_n}*r} where the x_i are the bits set to one in at least one but not all the elements of V, and r is made of the bits set to one in all the elements of V.

In your case you can observe that the two bound match and so the set C constructed by the second paragraph above (and actually equal to the one you suggested) is a solution of your problem.

EDIT

Based on the above, what about the following construction :

Let n be the numbers of bits in the binary representation maximal element of V.

Let S = {1, .., n}. Let T be the set of bits that are set to zero in all elements of V. Let S_0 be the set of bits that are set to one in all the elements of V. Let x_1 be the first element of S \setminus (T \cup S_0). Let S_1 be made of all the bits that take the same value as x_1 in all the elements of V. Let x_2 be the first element of S \setminus (T \cup S_0 \cup S_1). Let S_2 be made of all the bits that take the same value as x_2 in all the elements of V. Let x_3 .. .. and so on and so forth until S = (T \cup S_0 \cup S_1 \cup S_r).

Then C is obtained by considering the numbers x_0,x_1, .., x_r defined by x_i = sum_{j \cup S_i} 2^j

I am fairly convinced that this yield an optimal set C (altough I don't have a proof yet).

For instance in your example you would write in binary representation 3 = 0011 8 = 1000 9 = 1001 10 = 1010 11 = 1011

So T_0 = {3}, S_0 = {}, S_1 = {1}, S_2 = {2}, S_3 = {4}.

vib
  • 2,254
  • 2
  • 18
  • 36
  • Thanks for your quick and elaborate response! The first two paragraphs of your observations are identical to my own findings, which is good to see confirmed. The method you propose seems at least correct and near-optimal. I cannot think of a counterexample, so it might be worth trying to prove its correctness. – Arthelais May 28 '15 at 16:44
  • Don't forget to upvote the answer if you like it. I will think about a proof meanwhile when I have a time. – vib May 29 '15 at 11:26
  • I actually think my solution is not correct. A counter exemple is V = {2,3,5} where my algorithm does not find a set of size 2 as C = {2,3} – vib May 30 '15 at 13:58
  • I think the reason your algorithm worked was because in my example, C consisted of only powers of two, which suits the bit representation. – Arthelais May 31 '15 at 17:10