[algogeeks] Re: How to partition a set into two?

2006-07-10 Thread Ioannis Atsonios
It is true that the problem is NP-complete,albeit as DHyanesh said you can solve it via dynamic programming,the complexity of the algorithm is O(nW)(it is pseudopolynomial,because the W is proportional to the input represantation,which is unfortunately exponential). But you can find an approximati

[algogeeks] Re: How to partition a set into two?

2006-07-10 Thread Dhyanesh
This is a NP hard problem. There is no efficient way to solve it quickly, though if you have small numbers you can do it with Dynamic Programming in a way very similar to the Knapsack problem in O(sum*n) time, where "sum" is sum of all the integers and 'n' is the number of integers you have. -Dh

[algogeeks] Re: How to partition a set into two?

2006-07-10 Thread adak
Can't say that it's efficient, but it's thorough: Generate all the possible combinations of the integers (not permutations), and compare their sums to each other. Keep in mind that the integers you *don't* pick for one sub-group, are automatically part of the second sub-group, which was "left beh