Talk:Subset sum problem

message: Can you guys be a little more kind please?
>N, the number of decision variables
   What is 'decision' variable?
>P, the precision of the problem (stated as the number of binary place values that it takes to state the problem).
   What 'is binary place values' ? I don't get it really.
   Can you please explain it with examples?  —Preceding unsigned comment added by 61.101.222.27 (talk) 11:21, 11 April 2010 (UTC)
thread_title: Questions about recent addition

message: The general discussion section states that subset sum is not an optimization problem, but a few lines later it says that there is an approximation algorithm for subset sum. By definition, an approximation algorithm is a solution to an optimization problem, so these two statements seem to be contradictory. 
Shlurbee 17:32, 23 December 2005 (UTC)
replies: text: I've made the change to 'approximate' algorithm in the section title. There should also be some qualification made where the piped link to approximation algorithm occurs, such as 'although SSP is not strictly ...' . Charles Matthews 08:03, 24 December 2005 (UTC)

text: The trouble with cutting out all 'thinking aloud' sections is that it tends to make the coverage as a whole less accessible to non-experts. So please don't remove it, if it can be improved instead. Charles Matthews 08:37, 24 December 2005 (UTC)
thread_title:  Accuracy problems with "General discussion" section 

message: It is clearly stated that Q(1,s) is true. For any natural number n (excluding 0) we have: Q(n, 0) implies Q(n+1, 0) therefore for any natural n Q(n, 0) is true. This correspond to situation when we take an empty subset. IMO the algorithm should be changed to the fallowing:
----
The problem can be solved as follows using dynamic programming. Suppose the sequence is 
:x1, ..., xn 
and we wish to find a subset which sums to 0.  Let N be the sum of the negative values and P the sum of the positive values.  Define the function  
:Q(i,s)
to be 0 if there is no subset of x1, ..., xi which sums to s; 1 if there is a nonempty such subset; or 2 if only empty subset sumst to s (i.e. when s is zero).
(Thus, the value we really want is whether Q(n,0) is 2.)
Clearly 
:Q(i,s) = 0 
if s<N or s>P. Create an array to hold the values Q(i,s) for 1≤i≤n and N≤s≤P.  The array can now be filled in using a simple recursion.  
Initialize all Q(1, s) to 0. Let Q(1, 0) be 1. Let Q(1, x1) be 2. For i>1, if Q(i-1,s-xi) is nonzero let Q(i,s) be 2 otherwise let it be value of Q(i-1,s).
----
Moreover, I think it should be clearly stated that we are interested only in nonempty subsets.
Correct me if I'm wrong or correct the article if I'm right :) -- mina86, 217.96.228.130 11:09, 3 April 2006 (UTC)
replies: text: You are wrong. By convention, \sum_{x \in \emptyset} x is 0. --Mellum 12:43, 29 April 2006 (UTC)
replies: text: (nullary sum. :)
On the page itself, the quote reads: The running time is of order O(2^N N), since there are 2^N subsets and, to check each subset, we need to sum at most N elements.
This is specifically talking about a computer program (or Turing machine if you like) running an algorithm to solve the problem. The notation is introduced for the specific purpose of calculating the running time.
It seems perfectly obvious that the program will never perform any calculations on the empty set, so the existence of the empty set does not have any effect on the running time. Therefore, there are only 2^N -1 subsets being used to calculate the running time, and the running time is O(2^N-1 N).86.151.205.224 19:38, 8 September 2007 (UTC)
thread_title: Dynamic programming solution is incorrect?

message: Almost everywhere that I have seen subset-sum defined has defined the numbers in the set to be either over the natural numbers or the positive integers.  This is certainly so for Garey/Johnson and CLRS, the stated sources.  Shouldn't our definition follow these canonical sources?  Fremerl 19:22, 13 January 2007 (UTC)
thread_title: awkward definition

message: I have rephrased the intro here to expressed the problem as finding some non-empty subset for which the sum equals exactly zero. For a layman, at least, the use of any is ambiguous, and suggests that the sum of any subset equals zero. Others may feel that any is more precise, and want to revert this change. That's OK, but perhaps you could find some choice of words that's not ambiguous for the lay reader. Rupert Clayton 12:11, 6 February 2007 (UTC)
thread_title: "any" vs. "some"

message: The statement in the generalizations section, "[the subset sum problem] can actually be defined using any group", is not exactly accurate. For example Z_2 (integers modulo 2) under addition is a group, but finding the answer to the subset sum problem for a set of integers in Z_2 alone is trivial - the power set of Z_2 contains only four sets. Thus, I believe n must be a parameter of the problem, rather than as any particular fixed number (which "it can actually be defined using any group" seems to imply is allowed). I will rephrase the offending line. -- Ben-Arba 18:50, 11 February 2007 (UTC)
thread_title:  Generalizations 

message: Something is wrong, here.  First, the conventional definition of an approximation algorithm is for optimization problems (specifically, problems where the answer is a number), not decision problems (where the answer is just "yes" or "no").  For an optimization problem, an approximation algorithm is one that is guaranteed to produce an answer "close to" the right answer, for some appropriate definition of "close to".  But what is an approximation algorithm for a decision problem such as subset sum?
The definition given doesn't work because it's not symmetric about the target s -- if there's a subset whose sum is a little bit less than s, the algorithm might say "yes".  However, if there are no subsets whose sum is between (1 − c)s and s, the algorithm must say "no", even if there is a subset whose sum is s + ε for ε as small as you want.
Is there a refereed, published source for this algorithm or is it original research?
Dricherby (talk) 16:38, 3 July 2008 (UTC)
thread_title:  Approximation algorithm 

message: So a sorted list can be solved in linear time? Isn't this algorithm only searching for subsets of two elements? I don't get this section and can't find any web references.
MadCow257 (talk) 03:44, 3 March 2009 (UTC)
replies: text: As well as all the other reasons (it's redundant with the previous sentence, it's overly fawning and unobjective, and it assumes implicitly that N is the only variable worth using in the analysis), here's another for removing it: it's blatantly wrong. In particular the simpler algorithm that is like the Horowitz-Sahni one but uses a comparison sort instead of the more clever merge idea is O(2N/2 N), which is better than 2N, and there are lots of other ways of taking some similar algorithm and slowing it down, making a different algorithm that is better than 2N. —David Eppstein (talk) 19:33, 18 March 2011 (UTC)
replies: text: It's not redundant with the previous sentence because the previous sentence says there is no algorithm with a better worst-case running time, where the new sentence says that there is no algorithm with a different strategy than that of Horowitz and Sahni that beats the O(2N) brute force search strategy. It's not blatantly wrong. The choice of which type of sorting method to use is irrelevant, as the strategy of sorting subset-sums is still the same. Also, show me an algorithm that solves all instances of subset sum in the literature that doesn't use the strategy of sorting subset-sums and runs in o(2N) time. If you can, then the new sentence is wrong.Logicker (talk) 22:09, 18 March 2011 (UTC)
replies: text: A strategy is not the same thing as an algorithm. And here's a different algorithm: loop for 1.5N steps doing nothing, then run Horowitz/Sahni. Here's a third algorithm: split the problem into thirds, find all sums of subsets within each third, merge two of the thirds, and finally compare the merged result with the remaining third, time something like 22N/3. Finally, what we say in a Wikipedia article needs to be supported by sources in the literature — we should not be adding our own editorializations. If a source in the literature makes a point about nothing else coming close to Horowitz/Sahni then we can quote that, but it's not the kind of thing we should be making up ourselves. —David Eppstein (talk) 22:56, 18 March 2011 (UTC)
replies: text: What about Binary Decision Diagrams (later BDDs)? They can be used to solve #P-complete problem of calculating power indices in voting games in O*(2^(n/2) (google Bolus 2011). Calculating power indices is like counting all the possible solutions of several subset sum problems. In fact BDDs can be used for any threshold function in such time. #P-complete problems are at least as difficult as NP complete. Polynomial time reduction from subset sum to calculating power indices clearly yealds O*(2^(N/2)) algorithm with different strategy - by means of Binary Decision Diagrams. Example of such reduction from subset sum instance to power indices instance: take subset sum + 1 as voting game quota, take players weights as numbers in subset sum, add player with weight 1, calculate absolute Banzhaf power index of added player. The calcualted value multiplied by 2^n is equal to the number of subsets summing to orignal subset sum in original problem. This will work only for positive numbers in subset sum but surely can be adapted for negative also. Btw, all reasoning here is a bit of overkill and Binary Decision Diagrams should be directly applicable to subset sum problem. Bartosz Meglicki (talk) 00:31, 13 December 2011 (UTC)
replies: text: And what about it? You want to mention it in the article? If you can cite a reliable source with what you just said - how this algorithm can be applied to the subset sum problem and solve it in O(2^(n/2)) time, then by all means go ahead and add this information to the article. Otherwise, I don't think this should be added: O(2^(n/2)) is better than O(2^(n/2)*n) of Horowitz-Sahni, bold claims require bold evidence. We can't cite your words on the talk page here in the article as this would be original research. And "google Bolus 2011" - I don't see anything there. -- X7q (talk) 20:40, 23 December 2011 (UTC)
replies: text: You mistake the intent of my comment. I was reffering to the incorrect sentence by Logicker: "...no algorithm that solves all instances of the subset sum problem that uses a different strategy than that of Horowitz and Sahni's algorithm has ever been found to run faster than the order of 2N time in the worst-case scenario.". It has been found, it is not new, it is Binary Decision Diagrams algorithm. Also I never said it was O(2^(n/2)) but O*(2^(n/2)). '*' in the notation means 'suppressing polynomial factors' and was used for underlining the 2^(n/2) factor (which is plainly faster than 2^n in the cited sentence). My mistake for reffering to Bolus algorithm, it only made the comment difficult to understand. But that algorithm (and mentioned translatation to subset sum problem algorithm) has interesting properties: expected O(n^(2^n/2)) complexity along with pseudopolynomial complexity (like dynamic programming for subset sum) and solves #subset-sum (counts the number of all valid solutions as opposed to 'yes'/'no' decision algorithm). The paper was http://www.sciencedirect.com/science/article/pii/S0377221710006181 or the freely available preprint http://www.informatik.uni-kiel.de/~stb/files/SimpleGamesBDDs_2010.pdf. Bartosz Meglicki (talk) 09:46, 27 December 2011 (UTC)
thread_title:  Horowitz and Sahni 

message: I could not understand the dynamic programming example because it uses weird notation. I apologize for being naive, but what does the := operator do. Wouldn't it be easier to write that example using if-else notation.  —Preceding unsigned comment added by 97.123.190.39 (talk) 16:06, 11 August 2009 (UTC)
thread_title:  Trouble reading dynamic programming example 

message: Some anonymous editor has repeatedly attempted to replace the time bounds of the form O(2n/2) with O(1.414n), claiming that it looks nicer.
*It is not true that 2n/2 is O(1.414n). You can't mix overestimates (big O notation) and underestimates (rounding down √2 to the nearest smaller decimal) in this way. It would be mathematically correct to write that 2n/2 is O(1.415n). It would also be mathematically correct to write that 2n/2 is O(179n). Neither one of these overestimates is as precise as the original formula.
*The broader context is a section in which a somewhat subtle algorithm is being used to achieve a time bound of O(2n/2), when a simpler algorithm would achieve O(n2n/2). The subtler algorithm is faster by a factor of n. But both 2n/2and n2n/2 are O(1.415n), so replacing the exact formula by an approximate decimal loses all of the distinction between these two algorithms.
For these reasons I have reverted the change and intend to continue reverting it if it is made again. —David Eppstein (talk) 05:56, 17 January 2011 (UTC)
thread_title:  2^{n/2} vs 1.414^n 

message: Currently the complexity section uses terms like "decision variable" and "precision" of the problem without explaining what these terms are or how they are concretely represented in the subset sum problem. For those who don't already know the mapping, this makes the section fairly useless. --Mark viking (talk) 18:59, 4 April 2013 (UTC)
thread_title:  Unsatisfactory Complexity section 

message: The standard reduction from 3-Sat to subset sum implies that there is no 2^{o(n)} algorithm for the subset sum problem, unless ETH fails.
ETH is the exponential time hypothesis that can be also found on wikipedia.
Does anyone know a source, where this is mentioned?
I think it should be mentioned, as it shows that we cannot hope for much better algorithms.
An introduction to ETH can be found in the new parametrized complexity book:
http://www.barnesandnoble.com/w/parameterized-algorithms-marek-cygan/1122052557  — Preceding unsigned comment added by Tillmannberlin (talk • contribs) 11:34, 17 November 2015 (UTC)
thread_title:  NO ETH based lower bound mentioned 

message: The introduction contains the formulation:
"The problem is known to be NP-hard. Moreover, some restricted variants of it are NP-complete too"
I interpreted the "too" in the sense of "The problem is NP-hard. Some restricted variants are not only NP-hard, but even NP-complete."
Can we change the first sentence into "The problem is known to be NP-complete" to avoid this ambiguity?  — Preceding unsigned comment added by 77.57.114.138 (talk) 12:20, 30 September 2023 (UTC)
replies: text: Looks ok to me. Many NP-hard problems have a complication that the natural formulation is not actually in NP, because it is an optimization problem rather than a decision problem, but that doesn't appear to be an issue here. —David Eppstein (talk) 16:45, 30 September 2023 (UTC)

text: After trying to figure out for a while how SSP could possibly be NP-hard but not NP-complete, and only understanding the phrasing after reading this, I'll be bold and make the change. 195.114.237.210 (talk) 12:31, 23 May 2024 (UTC)
thread_title:  Misunderstandable formulation