Questions tagged [subset-sum]

In computer science, the subset sum problem is one of the important problems in complexity theory and cryptography.

In computer science, the subset sum problem is one of the important problems in complexity theory and cryptography.

424 questions
2
votes
1 answer

Reducing Subset Sum Problem to positive numbers only

I want to know is there is a way to reduce a Subset Sum problem with a set 'A' with negative and positive integers to the same problem but only with positive numbers.
Pedro
  • 141
  • 4
2
votes
2 answers

Subset sum Algorithm with modification

Given an array of positive integers and an upper limit MAX, i have to find the sub-sequence with sum <= MAX. There can be many sub-sequences whose sum is <= MAX . We have to find that one with max sum possible. I am not looking for the…
Dhruv Chandhok
  • 780
  • 7
  • 18
2
votes
1 answer

Subset Sum TI Basic Programming

I'm trying to program my TI-83 to do a subset sum search. So, given a list of length N, I want to find all lists of given length L, that sum to a given value V. This is a little bit different than the regular subset sum problem because I am only…
garrett
  • 21
  • 1
2
votes
1 answer

This puzzle- subset sum?

In today's edition of the Guardian (a newspaper in the UK), in the "Pyrgic puzzles" section on page 43 by Chris Maslanka, the following puzzle was given: The 3 wise men ... went to Herrods to do their Christmas shopping. Caspar bought Gold,…
jjs
  • 23
  • 3
2
votes
2 answers

Finding a subset of numbers that equals a single number

The reason I place this post is that I am looking to reconcile customer accounts receivable accounts where "payments" are posted to accounts instead of matched with the open invoices and cleared. So here is my issue: Have a single number (payment)…
John G
2
votes
1 answer

Algorithm to check for a linear sum to zero

Given a list of N non-negative integers, propose an algorithm to check if the sum of X numbers from the list equals the remaining N-X. In other words, a simpler case of the Subset sum problem which involves the entire set. An attempted solution Sort…
Furlox
  • 23
  • 2
2
votes
1 answer

Pseudo polynomial or fast solution for the multiobjective subset-sum

I am looking for a fast solution for a multiple/multiobjective subset-sum problem. As aditional restraints (which make a litte easier to calculate IMO) we can assume that all values included in the sum are positive and are all bound to a known limit…
1
vote
1 answer

How to quickly tell if any any subset of this set satisfy this condition?

I know this is an NP-hard problem, but a lot of our users have been requesting this feature (basically, does any set of the items in your current order qualify for one of the deals we have running? Or does any set of the items in your current order…
Drew
  • 12,578
  • 11
  • 58
  • 98
1
vote
1 answer

Effect of number base when proving NP completeness of numerical problems

I am reading about NP completeness from the algorithm design book of tardos, In the section of proving subset sum is NP complete, it is written that - The algorithm developed for subset sum has running time of O(nW). If an instance of 100 numbers is…
ocwirk
  • 1,079
  • 1
  • 15
  • 35
1
vote
3 answers

How does this solution of the subset sum problem work?

this is a solution for the subset sum problem. It uses backtracking. I have been thinking about it for more than 2 hours now and i just cannot understand it. edit:I have added some comments to the code based on what i have understood. Please…
Chaitanya Nettem
  • 1,209
  • 2
  • 23
  • 45
1
vote
1 answer

Need optimization tips for a subset sum like problem with a big constraint

Given a number 1 <= N <= 3*10^5, count all subsets in the set {1, 2, ..., N-1} that sum up to N. This is essentially a modified version of the subset sum problem, but with a modification that the sum and number of elements are the same, and that the…
svok
  • 13
  • 4
1
vote
0 answers

How to get a subset from maximum size subset with given sum solution [C]

I need to find a maximum size subset from a set of numbers which will have a given sum X. I've found a solution which solves this: // A Dynamic Programming solution for the // subset sum problem+ maximal subset size. #include using…
rongard
  • 89
  • 7
1
vote
1 answer

Divide a set of numbers into k subsets such that values are evenly distributed

Possible Duplicate: equal k subsets algorithm Say I've a set of numbers, I want to divide the numbers into k subsets such that the numbers are evenly distributed. By evenly distributed, I mean the sum of values in the subsets are closest to other…
4sh1sh
  • 751
  • 1
  • 5
  • 9
1
vote
1 answer

randomly find a combination from an array with duplicate elements and it's sum equal n

How can I randomly find a combination from an array with duplicate elements and it's sum equal n. Example array is [1, 2, 2, 3] and n is 3 answers are 1+2, 1+2, 3 If randomSubsetSum(array, n) is solution, then randomSubsetSum([1,2,2,3], 3) will…
xmcx
  • 283
  • 3
  • 18
1
vote
1 answer

How to loop over subsets of length k of a list of length n in R?

I am given two numbers n and k with 0 < k < n. How can I loop over all possible combinations of subsets of length k? E.g. I have x <- 1:10. Then I want to do for (y in c(c(1,2,3), c(1,2,4), c(1,2,5), ..., c(8, 9, 10))){ ... }
Corram
  • 233
  • 1
  • 3
  • 13