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
2 answers

Algorithm for finding a sum within an array?

Say you have some array with elements that you know are all positive, and smaller than a number N. Can someone give me a general, high-level description of an algorithm to find out whether there is some subset within the array in which all the…
Govind Parmar
  • 20,656
  • 7
  • 53
  • 85
-3
votes
2 answers

Subset sum problem with continuous subset using recursion

I am trying to think how to solve the Subset sum problem with an extra constraint: The subset of the array needs to be continuous (the indexes needs to be). I am trying to solve it using recursion in Java. I know the solution for the non-constrained…
Dani
  • 719
  • 1
  • 7
  • 14
-3
votes
1 answer

Subset sum approach for natural numbers

There is an array of n elements where any element is a natural number. To find a sum if present in the array without duplication while adding Approach Remove all elements greater than the sum Sort the array in descending order Setting currentsum to…
-4
votes
2 answers

Subset Sum Algorithm with just for loops

Is it possible to write a subset sum algorithm with just for loops? I would assume the run time would be O(2^n)
1 2 3
28
29