Whether P is equal to NP is one of the most famous unsolved problems in computational complexity theory, a NP-complete problem, if we can find a polynomial-time algorithm to solve it, then the P=NP is explained.
Today, 0-1 knapsack problem has been proved to be NP complete problem, but it has a dynamic programming solution, this solution has the time complexity of O (n*w), where n is the number of items, W is the maximum weight of backpack constraints. So the time complexity is polynomial time for the input n,w, so the np=p is explained. Is there something wrong?
In fact, polynomial time is relative to the size of the input, the most intuitive input scale is the input to the algorithm data accounted for how many bits of memory. 0-1 the input of the backpack has the value of n items, the weight of n items, and the maximum load W of the backpack. Now assume that W occupies the number of bits L (that is, the maximum weight of the backpack input size is L), then log (W) =l, so O (n*w) =o (n*2^l), it is seen that the time complexity of the algorithm for the input scale L is a number of degrees, with the increase in the size of input L, The computation time will grow rapidly.
In fact, this kind of dynamic programming algorithm is called the Pseudo polynomial time algorithm, and the algorithm can't solve the problem in pseudo-polynomial time in real sense.