Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split X into Y and Z where Y = Z (NP-issue)
#2
Are all the integers in set X explicitly/assumed to be sorted in ascending order?

What I'm about to say assumes the above is true.

Devil's Sunrise Wrote:Next step here would then be to check if i numbers equal to half the sum of X, starting from 1, incrementing by 1 until i is over half of the amount of numbers in X. While we do this, we check if all the solutions are over half the sum of X (if it is, then sorry, no solution).
Two interpretations...

1.) If I'm understanding this correctly, you're adding the sum of the numbers in indexes [i-j] (i through j inclusive), where the sum of the numbers in indexes [i-(j-1)] < Sum(X) / 2, and seeing if this is over Sum(X) / 2.

Counter-proof: X = { 1, 5, 5, 7, 7, 15, 30 }

2.) You're adding the sum of the numbers in indexes [i-j], where j - i = over half the elements in set X, and you're checking if the sum of the numbers in indexes [i-j] are higher than Sum(X) / 2.

Counter-proof: X = { a, a }

(yeah that was lame xD)

With the initial assumption, it seems you only really need to check one solution.
Reply


Messages In This Thread
Split X into Y and Z where Y = Z (NP-issue) - by KajitiSouls - 2009-01-20, 09:58 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)