0/1 Knapsack - How is it NP Complete?
Knapsack problem is called Weakly NP complete or pseudo-polynomial.
Time complexity of solving it is - O(n*W) .The value of W is linear but the length of W is exponential - length in terms of bits.
Pseudo polynomial means - running time is a polynomial in the numeric value of the input, but not in terms of the length of the input.
This
O(n * W)
can be rewritten asO(n * 2ʲ)
, which exponential in the size of the input.
Refernces:
https://en.wikipedia.org/wiki/Pseudo-polynomial_time
https://stackoverflow.com/questions/3907545/how-to-understand-the-knapsack-problem-is-np-complete
http://www.derf.net/knapsack/#KnapNP
I think it is more to do with computational Complexity theory than to do with real life problem solving.