Polynomial time solvable cases of the knapsack problem.

223 Views Asked by At

Is there some restricted version of the knapsack problem, which is not $Np$-complete and there is a polynomial time algorithm?

In my cases the weights are all power of $2$, so $(1, 2, 4, 8, 16, \ldots)$.

Are there any papers that deal with this special case?

2

There are 2 best solutions below

0
On

Your case is easy, it's just calculating the binary representation of a number i.e. Euclid's algorithm. (So, I do not think there are any special papers on this case, no.)

0
On

Hint: base $2$ expansion of $N$ gives you the unique way to write any $N$ as a sum of distinct powers of $2$.