X

DAYS

:

HOUR

:

MINS

:

SEC

How is the subset sum problem a special case of the knapsack problem ?

I need to know how the subset sum problem can be modeled as a knapsack problem. If I take the value of each number to be the weight, and the target sum to be the maximum weight of the knapsack I can model it as if putting objects in the knapsack, also I have to consider that every value is same for this to work.

But this reasoning falls apart when I am thinking about negative numbers. For example {-7, -3, 5} if I wanted a subset that adds up to -10, then how would I model this as a knapsack problem ?

 

What would be the base condition ? What will be the initial weight of the knapsack ?

Author: sreyan32
Login to Answer
Sort By:
Oldest
|
Newest
|
Vote
|
My Answer