Problem 2. In the Subset-Sum problem the input consists of a set of positive integers X = {x1, . . . , xn}, and some integer k. The answer is YES if and only if there exists some subset of X that sums to k.
In the Bipartition problem the input consists of a set of positive integers Y = {y1, . . . , yn}.
The answer is YES if and only if there exists some subset of X that sums to (Pn i=1 xi)/2.
We saw in class that the Subset-Sum problem is NP-complete. Show that the Bipartition problem is also NP-complete.
Hint: Devise a polynomial reduction from Subset-Sum to Bipartition. In your reduction you start with an input X, k of Subset-Sum and you construct an input Y of Bipartition. The goal is that there exists some subset of Y that sums to (P y∈Y y)/2 if and only if there exists some subset of X that sums to k. To that end, it might be a good idea to set Y to be equal to X, together with some additional integers that somehow encode k.
It is easy to see that SET-PARTITION can be verified in polynomial time; given a partition P1,P2P1,P2just sum the two and verify that their sums equal each other, which is obviously a polynomial time verification (because summation is a polynomial operation and we are only performing at most |X||X| many summations).
The core of the proof is in reducing SUBSETSUM to PARTITION; to that end given set XX and a value tt (the subset sum query) we form a new set X′=X∪{s−2t}X′=X∪{s−2t} where s=∑x∈Xxs=∑x∈Xx. To see that this is a reduction:
(⟹⟹ ) assume there exists some S⊂XS⊂X such that t=∑x∈Sxt=∑x∈Sx then we would have that
s−t=∑x∈S∪{s−2t}x,s−t=∑x∈S∪{s−2t}x,
s−t=∑x∈X′∖(S∪{s−2t})xs−t=∑x∈X′∖(S∪{s−2t})x
and we would have that S∪{s−2t}S∪{s−2t} and X′∖(S∪{s−2t})X′∖(S∪{s−2t}) form a partition of X′X′(⟸⟸) Suppose that there is a partition P′1,P′2P1′,P2′ of X′X′ such that ∑x∈P′1x=∑x∈P′2x∑x∈P1′x=∑x∈P2′x. Notice that this induces a natural partition P1P1 and P2P2 of XX such that WLOG we have that
s−2t+∑x∈P1x=∑x∈P2xs−2t+∑x∈P1x=∑x∈P2x
⟹s−2t+∑x∈P1x+∑x∈P1x=∑x∈P2x+∑x∈P1x=s⟹s−2t+∑x∈P1x+∑x∈P1x=∑x∈P2x+∑x∈P1x=s
⟹s−2t+2∑x∈P1x=s⟹s−2t+2∑x∈P1x=s
⟹∑x∈P1x=t⟹∑x∈P1x=t
Hence from a solution t=∑x∈Sxt=∑x∈Sx we can form a parition P1=S∪{s−2t}P1=S∪{s−2t}, P2=X′∖(S∪{s−2t})P2=X′∖(S∪{s−2t}) and conversely from a partition P′1,P′2P1′,P2′ we can form a soltuion t=∑x∈P′1∖{s−2t}xt=∑x∈P1′∖{s−2t}x and therefore the mapping f:(X,t)→X′f:(X,t)→X′ is a reduction (because (X,t)(X,t) is in the language/set SUBSETSUM ⇔X′=f(X,t)⇔X′=f(X,t) is in the language/set PARTITION) and it is clear to see that the transformation was done in polynomial time.
Problem 2. In the Subset-Sum problem the input consists of a set of positive integers X...
* SUBSET-SUM-kS, t> I S -[xi Xk] and for some lyı yn)cIxi.... xk) the sum of the yi's equals t. For example, <S-2, 3, 5, 7, 11, 14], t-21> is in SUBSET-SUM because 3+7 11-21. xk) can be partitioned into two parts A and -A where -A * SET-PARTITION <S> S-Ixi S-A and the sum of the elements in A is equal to the sum of the elements in A. For example, 〈 S-12, 3, 4, 7, 8/> works because...
Show that PARTITION is
NP-complete by reduction from SUBSET-SUM.
Given a set of integers, we say that can be partitioned if it can be split into two sets U and V so that considering all u EU and all v € V, Eu = Ev. Let PARTITION = { <S> S can be partitioned ). Show that PARTITION IS NP-complete by reduction from SUBSET-SUM.
(Erdos, distinct sums problem). k positive integers x_1,...,x_k are said to have distinct sums if the sum of any subset of them are different. Let f(n) denote the maximal k for which there exists such set within [n]. (a) Come up with a simple example of a set in [n] of size log_2 n. (Hint: binary expansion..) (b) Show that n >= (2^k * 2/3 - 1) / sqrt(3k)
In this assignment, you will prove that the Zero Sum problem is NP-Complete. The Zero Sum problem accepts an array of n integers and returns whether it is possible to negate some of those integers to make the array sum equal 0. For example, the array data = [1, 3, 5, 7, 9, 11] has a zero sum if you negate the 7 and 11, while the array data = [1, 2, 5, 9, 13, 22] cannot be reduced to...
Subset Sum-2 Write an algorithm (in comments) and specify the big O, and a C program to solve the problern below. Read the input for the set elements, the value of K from the user. Assume the size of the set is not bigger than 20. Subset Sum-3 Write an algorithm (in comments) and specify from the user. Assume the size of the set is not bigger than 20 1. Given a finite set of integers, is there a subset...
5. The Hitting Set Problem (HS) is the following decision problem. Input. A finite set S, a collection (s1, s2,... , sn) of subsets of S, and a positive integer K. Question. Does there exist a subset t of S such that (a) t has exactly K members and (b) for i 1,..., n, sint6For example, suppose S # {1, 2, 3, 4, 5, 6, 7. the collection of subsets is (2.45), (34).(1,35) and K - 2. Then the answer...
Write a java application to input 2 positive integers X and Y such that X is less than Y. Then the program should do the following: 1. Output the sum of even integers between 1 and X. 2. Output the average of odd integers between 1 and Y. 3. Output the common divisors of X and Y.
Give a decision problem corresponding to each of the search problems given below. (a) • Input: A set of classes to be scheduled. A list of pairs of the classes which can not be scheduled during the same period. • Output: The largest set of classes that can all be scheduled during the same period. Solution A • Input: A set of classes to be scheduled. A list of pairs of the classes which can not be scheduled during the...
Let X be a finite set and F a family of subsets of X such that every element of X appears in at least one subset in F. We say that a subset C of F is a set cover for X if X =U SEC S (that is, the union of the sets in C is X). The cardinality of a set cover C is the number of elements in C. (Note that an element of C is a...
Please do problem 14.12
Problem 14.6. Let X be a nonempty set and let A be a subset of X. The character- istic function or indicator function of the set A in X is 1 if x E A XA(x)-10 if xeX\A A-X→ {0,1} defined by Problem 14.12. See Problems 14.6, 14.7, and 14.11 for the definitions (a) Write the greatest integer function as a sum of characteristic functions (there may be more than one way to do this). Depending...