Sum of subset reduce to Partition 00366146 林季謙 Sum of Subset Problem • The Sum of Subset Problem (部份集合的和問題): ▫ 給予一組正整數的集合S={a1, a2, … , an}及一個常數c,問: 集合S中 是否存在一組子集合S’,此子集合S’的數字總合為c。 ▫ Ex: 假設有一個集合 S = {12, 9, 33, 42, 7, 10, 5} 與常數c = 24. ▫ 問 S’ = {9, 10, 5}的總和會不會等於 c ▫ 在此 C=24 所以 會回答Yes ▫ If C=6 會回答No Partition Problem ▫ 給予一組正整數的集合S={a1, a2, … , an},問: 是否可以將其分割成 兩個子集合S1與S2,而此兩個子集合的個別總和相等。 ▫ Ex: 設有一集合 S = {13, 2, 17, 20, 8}. ▫ S1 = {13, 17} and S2 = {2, 20, 8}. Proof Sum of subset reduce to Partition • Sum of Subsets : A = { a1, a2, …, an }, M • Partition : B = { b1, b2, …,bn,bn+1,bn+2 }, and bi = ai, 1<i<n • 設bn+1=M+1 • bn+2=( )+1-M • Consider a sum of subset problem S with {a1, a2, … , an} and B. • Let SUM(ai)=M for i= 1, 2, … , n. • We find an integer Q s.t. B+Q= ½(M+Q). (or Q=M-2B) • Let the corresponding partition problem instance P be {Q,a1,a2,…,an}. • We can partition P if and only if there is some subset of S that sums to B. • Ex. S={5, 7, 3, 8} and B=11. Set Q=M2B=23-22=1. Then. P={1, 5, 7, 3, 8} has a partition {1, 3, 8}//{5, 7}.The former contains a subset with sum B=11. Sum of Subsets : A = { a1, a2, …, an }, M Partition : B = { b1, b2, …,bn,bn+1,bn+2 }, and bi = ai, 1<i<n 設bn+1=M+1 bn+2=( )+1-M 假設有一個Sum of subset 的解 S 即 那麼 假設有一個partition的解,然而 ( )則存在S 需要不一樣且