

The Easiest Hard Problem: Balanced Number Partitioning - cperciva
http://www.americanscientist.org/template/AssetDetail/assetid/14705?&print=yes

======
cperciva
This is a generally good article, but it gets two things irritatingly wrong.
First, it presents the problem as only existing in the case of partitioning
into two sets; in fact, the problem is usually considered in the case of
partitioning into three or more sets, since the two-set case is really just
the (far more widely known) Subset-Sum problem.

Second, the article gives an example of a two-set partitioning problem and
then states that "the only sure way to find the one perfect partition is to
check all possible partitions", i.e., that the optimal algorithm runs in
O(2^N) time. In fact, there is a trivial O(sqrt(2)^N) algorithm for the
problem.

~~~
bayareaguy
Where can I read more about the O(sqrt(2)^N) algorithm?

~~~
cperciva
The gist of the algorithm is covered in
[http://en.wikipedia.org/wiki/Subset_sum_problem#Exponential_...](http://en.wikipedia.org/wiki/Subset_sum_problem#Exponential_time_algorithm)

Going from the O(2^(N/2) N) algorithm described in the wikipedia article to
O(2^(N/2)) just involves keeping the lists of subset sums sorted during the
construction process, thereby avoiding the need for the expensive sorting
step.

That said, the O(2^(N/2)) algorithm requires O(2^(N/2)) space, making it less
than ideal; in most circumstances, an algorithm which generates the lists of
subset sums for each half of the list on-demand using a priority queue is
better -- this approach takes O(2^(N/2) N) time, but only O(2^(N/4)) memory.

