문제

I am reading about NP completeness from the algorithm design book of tardos, In the section of proving subset sum is NP complete, it is written that -
The algorithm developed for subset sum has running time of O(nW). If an instance of 100 numbers is given, each of which is 100 bits long then the input is only 100 * 100 = 10000 digits, but W is roughly 2^100.
I dont understand this claim, why is W 2^100 ? what is the effect of base on this problem, I mean if we change it to some other base x, would W be x^100 ? what if we change it into unary base ?
thanks.

도움이 되었습니까?

해결책

To understand this you need to think about how the running time of the algorithm changes as the size of the numbers in the problem set grows. I'm assuming that your textbook describes the usual dynamic programming attack on subset sum. That algorithm's run time grows linearly with the width of the problem set. (The problem set width is the sum of the positive numbers in the set minus the sum of the negative numbers.) This width grows exponentially as you increase the size of the numbers in the set. For example, if you use 101 bit numbers instead of 100 bit numbers, the width of the problem set doubles. Move to 102 bit numbers and the problem set width doubles again. And since the algorithm's run time grows linearly with the problem set width, that run time doubles each time as well. This doubling is exponential growth in run time as the input size grows linearly, so this is not a polynomial-time algorithm.

If the numbers were written in a different base > 1, then yes, you would see exponential growth of the problem width in that base. For example, in base 10 adding another digit makes the problem width ten times larger. If you switch to unary, you lose the exponential growth in the problem set size, but instead the input size for any given problem is exponentially larger than it would be in bases > 1, so you gain nothing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top