Questions tagged [subset-sum]

Questions about the NP-complete problem Subset Sum.

Subset Sum is one of the canonical NP-complete problem. Given a set $S$ of positive integers and a target $B$, is there a subset of $S$ summing to $B$? An optimization variant asks for the subset of $S$ whose sums is closest to $B$.

Subset Sum is NP-hard if the integers in $S$ are encoded in binary (i.e., in the usual way), but if they are encoded in unary (that is, $n$ is encoded as $1^n$, the string consisting of $n$ many ones), a dynamic programming algorithm solves Subset Sum in polynomial time.

The trivial $2^n$ algorithm (where $n = |S|$) for solving Subset Sum can be improved to $c^n$ for some $c < 2$. Assuming SETH, there is no $2^{o(n)}$ algorithm. The best value of $c$ (conditional on SETH or similar hardness assumptions) is currently unknown.

123 questions
38
votes
4 answers

Generalised 3SUM (k-SUM) problem?

The 3SUM problem tries to identify 3 integers $a,b,c$ from a set $S$ of size $n$ such that $a + b + c = 0$. It is conjectured that there is not better solution than quadratic, i.e. $\mathcal{o}(n^2)$. Or to put it differently: $\mathcal{o}(n \log(n)…
bitmask
  • 1,765
  • 2
  • 16
  • 20
11
votes
2 answers

Subset sum problem for permutations

Given permutations $g_1,\,\ldots, g_m \in S_n$ of size $n$ and target permutation $g \in S_n$, decide if there exists a subset of $\{g_1,\, \ldots, g_m\}$, which composition in some order (or, alternatively, as a variant of this problem, in the same…
5
votes
1 answer

Is there a name for this modification to the subset sum problem?

Let $S = \{\{x_{1},y_{1},z_{1}\},\{x_{2},y_{2},z_{2}\}, \ldots, \{x_{n},y_{n},z_{n}\}\}$ and a target $t$. Let $S_i$ be the subset list $\{x_{i},y_{i},z_{i}\}$. Find a subset sum that sums to $t$ such that one and only one element is chosen from…
Joshua
  • 51
  • 1
5
votes
1 answer

Enumerate all valid orders of subset sums

Given an positive integer $n$, we define an order of subset sums (or simply, an order, when there is no ambiguity) to be a sequence of all subsets of $\{1,\ldots,n\}$. For example, when $n=2$, the sequence $\emptyset,\{1\},\{2\},\{1,2\}$ is an…
xskxzr
  • 7,613
  • 5
  • 24
  • 47
5
votes
1 answer

Two versions of Subset Sum Problem

I keep seeing two versions of the Subset Sum Problem. The first and seemingly least common is: Given an integer bound $W$ and a collection of $n$ items, each with a positive integer weight $w_i$, find the subset $S$ of the items that maximizes…
kanso37
  • 445
  • 2
  • 14
4
votes
0 answers

Modified Subset Sum Problem

Given an array of $n$ integers $A$, and some value $m$, determine if it is possible, by using certain amounts of each element, to get a total sum equal to $m$. Consider that you can use any amount of any of the elements. This is sort of like the…
Mateus Buarque
  • 209
  • 1
  • 6
4
votes
1 answer

Subset Sum for {1,...,n}

In general, the subset sum problem is NP-Complete. However, what if we say that our set is $\{1,...,n\}$? Is there a formula/combinatorial calculation that says how many subsets of $\{1,...,n\}$ have their sum equal to $k$?
TheNotMe
  • 571
  • 1
  • 6
  • 18
4
votes
0 answers

Subset Sum Search Problem for Input with At Most One Solution

Edit: This question has been reasked on TCS. We first consider the search version of the subset sum problem: Given a set $S$ of $n$ naturals, find a subset of $S$ that sums to exactly $W$. My question concerns this problem, with an additional…
3
votes
3 answers

Find the lexicographically smallest order of N numbers such that the total of N numbers <= Threshold value

GIven a number N, Threshold T and an array A. Find the lexicographically smallest order of N numbers from A such that the total of these N numbers is <= T. This question is a simplification of this dynamic programming question: It’s Tushar’s…
3
votes
1 answer

What is the complexity class of this variant of Subset sum?

Let's represent Subset Sum problem with binary arrays instead of numbers. Example: given two-dimensional array [1, 0, 0] (4) [1, 0, 1] (5) [0, 0, 1] (1) is there set of one-dimensional arrays, sum of which is equal to [1, 0, 0, 1] (9) In this…
DSblizzard
  • 484
  • 1
  • 4
  • 10
3
votes
1 answer

Is integer factorization reducible to subset sum?

Is it possible to solve the FACT (integer factorization) problem in polynomial time if we know the polynomial Subset Sum algorithm? We assume that we know the algorithm solving the problem of Subset Sum with complexity: $n ^ 4 \cdot m ^ 4$ (for…
Aurelio
  • 239
  • 2
  • 6
3
votes
1 answer

Harder version of the k-partition problem

Given a sequence $q_1, \ldots, q_n$ of numbers, decide if the set $I=\{1,\ldots,n\}$ can be partitioned into $k$ sets $I_1, \ldots, I_k$ such that $\sum_{i\in I_1} q_i=\sum_{i\in I_2} q_i = \dots = \sum_{i\in I_k} q_i$. I know that the problem is…
Lisa E.
  • 555
  • 1
  • 18
3
votes
0 answers

Subset sum problem with big items

Consider the variant of the Subset Sum problem, where the input is a list of $2 m + 1$ positive integers of sum $2 S$, and the goal is to find a subset with the largest sum that is at most $S$. The problem is NP-hard in general, but it can be solved…
Erel Segal-Halevi
  • 6,088
  • 1
  • 25
  • 60
3
votes
1 answer

Linear-time constant-space 1/2-approximation algorithm for the maximum subset sum problem

The following problem statement is given: Let $S = \{s_1, s_2, \cdots, s_n\}$ be a sequence of unique positive integers and $K$ a positive integer, where $K \ge s_i$ for every $i$ between $1$ and $n$. The goal is to find a subset of $S$ whose sum…
3
votes
1 answer

Subset sum with only two item types

Suppose we have $r$ copies of the integer $a$ and $t$ copies of the integer $b$, and a capacity $C$. We would like to find the maximum sum of the given integers, that is at most $C$. This is a special case of the subset sum problem. Since there are…
Erel Segal-Halevi
  • 6,088
  • 1
  • 25
  • 60
1
2 3
8 9