DOC PREVIEW
Berkeley COMPSCI 170 - Lecture 24

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

U.C. Berkeley — CS170: Intro to CS Theory Handout N24Professor Luca Trevisan December 4, 2001Notes for Lecture 241 Some NP-complete Numerical Problems1.1 Subset SumThe Subset Sum problem is defined as follows:• Given a sequence of integers a1, . . . , anand a parameter k,• Decide whether there is a subset of the integers whose sum is exactly k. Formally,decide whether there is a subset I ⊆ {1, . . . , n} such thatPi∈Iai= k.Subset Sum is a true decision problem, not an optimization problem forced to becomea decision problem. It is easy to see that Subset Sum is in NP.We prove that Subset Sum is NP-complete by reduction from Vertex Cover. We haveto proceed as follows:• Start from a graph G and a parameter k.• Create a sequence of integers and a parameter k0.• Prove that the graph has vertex cover with k vertices iff there is a subset of the integersthat sum to k0.Let then G = (V, E) be our input graph with n vertices, and let us assume for simplicitythat V = {1, . . . , n}, and let k be the parameter of the vertex cover problem.We define integers a1, . . . , an, one for every vertex; and also integers b(i,j), one for everyedge (i, j) ∈ E; and finally a parameter k0. We will define the integers aiand b(i,j)sothat if we have a subset of the aiand the b(i,j)that sums to k0, then: the subset of the aicorresponds to a vertex cover C in the graph; and the subset of the b(i,j)corresponds tothe edges in the graph such that exactly one of their endpoints is in C. Furthermore theconstruction will force C to be of size k.How do we define the integers in the subset sum instance so that the above propertieshold? We represent the integers in a matrix. Each integer is a row, and the row should beseen as the base-4 representation of the integer, with |E| + 1 digits.The first column of the matrix (the “most significant digit” of each integer) is a specialone. It contains 1 for the ais and 0 for the b(i,j)s.Then there is a column (or digit) for every edge. The column (i, j) has a 1 in ai, ajandb(i,j), and all 0s elsewhere.The parameter k0is defined ask0:= k · 4|E|+|E|−1Xj=02 · 4iThis completes the description of the reduction. Let us now proceed to analyze it.Notes for Lecture 24 2From Covers to Subsets Suppose there is a vertex cover C of size k in G. Then wechoose all the integers aisuch that i ∈ C and all the integers b(i,j)such that exactly one ofi and j is in C. Then, when we sum these integers, doing the operation in base 4, we havea 2 in all digits except for the most significant one. In the most significant digit, we aresumming one |C| = k times. The sum of the integers is thus k0.From Subsets to Covers Suppose we find a subset C ⊆ V and E0⊆ E such thatXi∈Cai+X(i,j)∈E0b(i,j)= k0First note that we never have a carry in the |E| less significant digits: operations are inbase 4 and there are at most 3 ones in every column. Since the b(i,j)can contribute at mostone 1 in every column, and k0has a 2 in all the |E| less significant digits, it means that forevery edge (i, j) C must contain either i or j. So C is a cover. Every aiis at least 4|E|, andk0gives a quotient of k when divided by 4|E|. So C cannot contain more than k elements.1.2 PartitionThe Partition problem is defined as follows:• Given a sequence of integers a1, . . . , an.• Determine whether there is a partition of the integers into two subsets such the sumof the elements in one subset is equal to the sum of the elements in the other.Formally, determine whether there exists I ⊆ {1, . . . , n} such thatPi∈Iai= (Pni=1ai)/2.Clearly, Partition is a special case of Subset Sum. We will prove that Partition is isNP-hard by reduction from Subset Sum.1Given an instance of Subset Sum we have to construct an instance of Partition. Let theinstance of Subset Sum have items of size a1, . . . , anand a parameter k, and let A =Pni=1ai.Consider the instance of Partition a1, . . . , an, b, c where b = 2A − k and c = A + k.Then the total size of the items of the Partition instance is 4A and we are looking forthe existence of a subset of a1, . . . , an, b, c that sums to 2A.It is easy to prove that the partition exists if and only if there exists I ⊆ {1, . . . , n} suchthatPiai= k.1.3 Bin PackingThe Bin Packing problem is one of the most studied optimization problems in ComputerScience and Operation Research, possibly the second most studied after TSP. It is definedas follows:• Given items of size a1, . . . , an, and given unlimited supply of bins of size B, we wantto pack the items into the bins so as to use the minimum possible number of bins.1The reduction goes in the non-trivial direction!Notes for Lecture 24 3You can think of bins/items as being CDs and MP3 files; breaks and commercials;bandwidth and packets, and so on.The decision version of the problem is:• Given items of size a1, . . . , an, given bin size B, and parameter k,• Determine whether it is possible to pack all the items in k bins of size B.Clearly the problem is in NP. We prove that it is NP-hard by reduction from Partition.Given items of size a1, . . . , an, make an instance of Bin Packing with items of the samesize and bins of size (Piai)/2. Let k = 2.There is a solution for Bin Packing that uses 2 bins if and only if there is a solution forthe Partition problem.2 Approximating NP-Complete ProblemsWhat does it mean to approximate the solution of an NP-complete problem, when wehave so far been considering only questions with yes/no answers? Actually, many of theproblems we have looked at are most naturally stated as optimization problems, which we canapproximate. For example, in TSP the yes/no question is whether there is a cycle visitingeach node once of length at most K; the optimization problem is to find the shortest cycle;and the approximation problem is to find a short cycle, i.e. one whose length is as shortas one can afford to compute. Similarly, for Vertex Cover the yes/no question is whetherthere is subset of vertices touching each edge, of cardinality at most k; the optimizationproblem is to find the vertex cover with the fewest vertices; and the approximation problemis to find a vertex cover with few vertices, i.e. one whose cardinality is as small as one canafford to compute.To measure how good an approximation we compute, we need a measure of error.Suppose c > 00 is an approximation to the exact value c∗> 0. (For Vertex Cover, c isthe size of a vertex cover found by an approximate algorithm, and c∗is the true


View Full Document

Berkeley COMPSCI 170 - Lecture 24

Download Lecture 24
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 24 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 24 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?