将分区概率降低为决策概率

Reducing partition prob to decision prob

我们有相关的众所周知的问题:

1)PARTITION(决策题): 给定一个包含 n 个自然数的集合 S。是否可以找到S的子集T使得T的个数之和等于T\S的个数之和?

2) PARTITION(一般问题): 给定一个包含 n 个自然数的集合 S。假设决策问题1)对这个集合的答案是'yes'然后找到这样一个子集

简单的问题:如果我们有一个算法可以在多项式时间内解决 1),我们如何在多项式时间内解决 2)?

解决方案:假设我们要划分一组 S 的 n 个自然数,总和等于一个数 b 并且我们有一个黑盒算法来解决多项式的决策问题时间。

1: If the answer of the partition problem of S is no, then return. 2: Pick an element x of S. 3: If x is equal to b/2 return S\x (partition found). 4. Merge x with another element y of S (set x=x+y and set S=S\y) which is not processed yet. 5: Solve the decision problem for S. 6: If the answer is no then revert step 4, mark y as processed. 7: Go back to step 3.

每次我们重复步骤 2 时,我们都必须在多项式时间内解决一个决策问题。由于我们最多只需要重复第2步n-1次,所以整体的时间复杂度也是多项式的。