0

Recently I was given a question to

  1. Pick few numbers from these 34,32,43,46,36,21,28 such that their sum should nearest to 112 but should be less than that.

  2. Given few subsets A1,A2,A3...................An, find the optimal situation: Optimal situation has been defined as Minimum overlaps and Maximum elements coverage of the superset S with the help of union and intersection.

I have done the first one manually but how can I code for solution-I mean I want to know where I can find algorithms/methods for these types for coding.

Emin
  • 29
  • 4
  • The first one is a [binary knapsack problem](http://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_knapsack_problem) where the profit of each item is the same as its weight. The second one is not well-posed. Any set `S` can be partitioned to non-overlapping sets `A1, ...,An`, with some `Ai`s possibly equal to the empty set. Thus, a partition is a min overlap/max coverage solution. What are the constraints? – Ioannis Oct 07 '14 at 15:37
  • Thanks for your help, these subsets are not non-overlapping. I have edited the second part-please have a look! – Emin Oct 10 '14 at 17:44

1 Answers1

1

(1) is a so-called zero-one assignment problem. Find x1, x2, x3, ... which are either 0 or 1 such that 34*x1 + 32*x2 + 43*x3 + ... is less than 112. Zero-one assignment is a special case of integer linear programming. Search for those terms should turn up a lot of hits.

Not sure about (2). I guess it is a combinatorics problem but I don't know an existing category to classify it.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48