Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 683

Questions about the NP-complete problem Subset Sum.

2 votes

What are some concrete (near-)"worst-case" examples of subset-sum?

It's not clear how to formally define worst-case (or near-worst-case) instances, but here is something you could try. The idea is to combine the following two tidbits: We know some hard instances f …
Yuval Filmus's user avatar
1 vote
Accepted

Does the subset sum problem remain $NP$ complete when we increase word size and restrict num...

Your problem is not really well-defined, since it's not clear what is the parameter $n$. That said, under any reasonable interpretation, your problem is still NP-complete, as can be shown by padding. …
Yuval Filmus's user avatar
3 votes

Counting the number of subsets with positive sum

Suppose that you could solve this in $T(n)$. Given a list of positive integers $a_1,\ldots,a_n$ and a target $T$, consider the two instances $a_1,\ldots,a_n,-T$ and $a_1,\ldots,a_n,-T+1$. Denoting by …
Yuval Filmus's user avatar
1 vote
Accepted

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

This is A053632. The prefixes of this sequence convergence to the more well-known A000009, the number of partitions into distinct (or odd) parts. You shouldn't expect a clean formula, though it's of c …
Yuval Filmus's user avatar
1 vote

Algorithm for this problem on generating all permutations

Suppose that there are $n$ groups, that group $i$ has the $m_i$ elements $x_{ij}$. It is a nice exercise to show that the sum of weights of all valid vectors is $$ \prod_{i=1}^n \sum_{j=1}^{m_i} x_{ij …
Yuval Filmus's user avatar
2 votes
Accepted

Subset sum into a consecutive range vs. standard subset sum

This answer assumes that a Yes instance of your problem with elements $x_0,\ldots,x_{n-1}$ and targets $[X,X+1]$ is one in which there is a subset summing to either $X$ or $X+1$. Given an instance of …
Yuval Filmus's user avatar
2 votes
Accepted

Finding the Range of Solutions for KSum Variation

Suppose that the value at location $i$ is $j$. According to the continuity of $k$-sums (mentioned in an answer to the linked question), the range of possible sums of values at locations $1,\ldots,i-1$ …
Yuval Filmus's user avatar
1 vote

Minimizing the iterative sum of pairs of numbers in a list

Your problem is known as optimal alphabetic binary tree (or various similar names). This is an ordered version of Huffman coding, in which the two numbers being added don't have to be adjacent. The pr …
Yuval Filmus's user avatar
2 votes

Subset sum exponential solution - how does the sorting work?

The idea is that two sorted lists of length $n$ can be merged into one sorted list of length $2n$ in time $O(n)$. This is a standard procedure used in the mergesort algorithm. Given a list of integers …
Yuval Filmus's user avatar
1 vote

Confusion about dynamic programming on unconstrained subset sum vs constrained subset sum

If you have $n$ non-negative integers $x_1,\ldots,x_n$ in the range $0,\ldots,T$, then their susbets can sum up only to integers in the range $0,\ldots,nT$. This allows us to solve SUBSET-SUM efficien …
Yuval Filmus's user avatar
3 votes
Accepted

Two versions of Subset Sum Problem

Given an instance of the second problem, we can easily reduce it to an instance of the (decision version of) the first problem: simply take $W = k$. There is a subset of sum at least $k$ and at most $ …
Yuval Filmus's user avatar
3 votes
Accepted

Solve SUBSET SUM for Reciprocals of Primes

The observation is that the denominator of the reduced fraction $1/p_{i_1} + \cdots + 1/p_{i_m}$ is $p_{i_1} \cdots p_{i_m}$. To see this, it suffices to notice that the (unreduced) numerator isn't di …
Yuval Filmus's user avatar
2 votes

How to prove the NP-completeness of MOD-PARTITION

Showing that this your problem is in NP is easy. To show that your problem is NP-hard, reduce from PARTITION. The reduction simply chooses a large enough modulus $k$. Details left to you.
Yuval Filmus's user avatar
1 vote

find maximum sum of xors

For every $i \in \{0,\ldots,n\}$ (where $n$ is the length of the array) and for every $a,b,c \in \{0,\ldots,15\}$, we determine whether it is possible to partition the first $i$ elements of the array …
Yuval Filmus's user avatar