-6

Given a set of N objects with assigned weights, how would we find the set of K objects that is closest to the average? The average being sum(weights) / N.

Also, how could we compute the next set that is 2nd closest to the average, and continue on to the 3rd, 4th, etc.?

closed as unclear what you're asking by gnat, Jörg W Mittag, 8bittree, enderland, David Hammen Jun 18 '17 at 20:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What are you computing the mean over? The subset or the full set? And what measure are you using to compare a subset with the average? – CodesInChaos May 22 '17 at 14:37
1
  1. Calculate the average
  2. For each object calculate its difference from the average
  3. Sort by this difference.
  4. Take K objects from the top of the sorted list, and so on

Not the answer you're looking for? Browse other questions tagged or ask your own question.