1
$\begingroup$

Hi, i have a set of integers for example: {0,1,3,100,102} and i am looking for a maximum subset in which all elements have a minimum distance to all elements (or the "next" doesnt matter i guess) for my example ({0,1,3,100,102}) and the distance 3 the result could be: {0,3,100} for distance 2 it could be: {0,3,100,102}

Is there an "good" algorithm to do that ?

(This is my first post, sry when i chose the wrong tag)

$\endgroup$
4
  • 1
    $\begingroup$ You have chosen the wrong forum for this! Try posting it on stackoverflow.com -- you will get dozens of answers explaining how to solve your problem using dynamic programming. $\endgroup$
    – TonyK
    Jun 1, 2012 at 13:20
  • $\begingroup$ isn't this also a mathematical problem ? Something like the Knapsack problem ? $\endgroup$ Jun 1, 2012 at 13:36
  • $\begingroup$ here i got my answer: stackoverflow.com/questions/10852535/… $\endgroup$ Jun 1, 2012 at 15:28
  • $\begingroup$ To summarize: The obvious greedy algorithm works. $\endgroup$ Jun 1, 2012 at 18:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.