0% found this document useful (0 votes)
8 views2 pages

CIS262HW8

Uploaded by

clairezhaolj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

CIS262HW8

Uploaded by

clairezhaolj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CIS 2620 - Claire Zhao

Homework 8

Q1. We will prove that the problem A is NP-complete by proving that it is in NP and is NP-hard. First, we can prove that
A is in NP by proving there is a poly-time deterministic TM V such that input w is in A iff V accepts the input and
some certificate of size polynomial in |w|. The verifier will take in the set S as input and the subset U as a certificate.
Then, it will compute the sum of the numbers in S and then compute the sum of the numbers in S\U and accept if
they are equal, rejecting otherwise. This is done in polynomial time, since calculating the sum of the numbers in each
subset can be done in linear O(|S|) time and comparing the two sums is done in O(1) time. S belongs to A if and only
if the verifier accepts < S, U >. Thus, problem A is in NP.

Next, we can prove that A is in NP-hard by showing there is a language B in NP that reduces to A in polynomial-time.
Given the inputs S and k to B, we can calculate sum(S) and let this be m. If the sum of the numbers in U is k, it
follows that the sum of the numbers in S\U is m − k. We will add to the set S the numbers 2m + k and 3m − k
since if the sum of the numbers in subset U is k, then we can add the number 3m − k and the new sum of its numbers
is 3m − k + k = 3m. Furthermore, we can add the number 2m + k to S\U and the new sum of numbers would be
2m + k + m − k = 3m. We can see that both sum of numbers are equal. In the new updated set S the total sum of
the numbers would be m + 2m + k + 3m − k = 6m so each of the two elements added has to go to one partition to
preserve the equal partition. Conversely, the partition that 2m + k goes to must have an original sum of m − k so the
new sum is 3m and the partition that 3m − k goes to must have an original sum of k so that the new sum is 3m. Thus,
we have shown that language B reduces to A by showing that (S, k) is in B if and only if (S ∪ {2m + k, 3m − k} is in
A. The reduction is polynomial-time because calculating the sum m is done in linear time, computing and adding the
two elements is done in constant time, and we know B is NP-complete.

Q2. We will prove that the SET-PACKING problem is NP-complete by showing it is both in NP and NP-hard. To show
that it is in NP, we can show that there is a verifier that takes in the list of sets as input and integer k and a cer-
tificate C that encodes which is a subset of k indices indicating the selected sets. The verifier will check that the C
subset is of size k and check if every pair of sets in C does not share an element (ie their intersection is empty). This
requires checking all pairs of sets in the subset and check that their intersection is empty, accepting if all pairs have
an empty intersection, rejecting otherwise. This is a polynomial time verification because the machine can guess non-
deterministically in polynomial time and checks at most k2 pairs, which is polynomial in k, and the intersection check


also takes polynomial time. Thus, SET-PACKING is in NP because we have shown it can be verified in polynomial time.

We will show that SET-PACKING is NP-hard by showing the problem INDEPSET reduces to it. We need to construct
an instance of INDEPSET using SET-PACKING. We can convert each vertex in G to an individual set from the list of
sets, where each set Sv is represented in vertex v ∈ V . For each edge (u, v) ∈ E, sets Su and Sv must share a common
element. This is to say that each vertex vi , we define the corresponding set Si that contains the set of edges that involve
the vertex vi , so Si {j|vi is an endpoint of edge ej }. Given k from the SET-PACKING problem, we can use it as k
in the INDEPSET problem. Since we know that INDEPSET is NP-complete, it will return if the graph contains an
independent set of vertices of size k in polynomial time. This works because if there exists an independent set in G of
size k, it will identify the vertices with no edges between them and these will be the pairwise disjoint sets. Conversely,
if there are k pairwise disjoint sets in SET-PACKING, their corresponding vertices in G will form an independent set
of size k as they will not be adjacent. This reduction happens in polynomial time and SET-PACKING is therefore
NP-hard. Thus, SET-PACKING is NP-complete.

2 Homework 8

You might also like