11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Sec. 17.2 Hard Problems 549str<strong>at</strong>egy is to replace any clause C i th<strong>at</strong> does not have exactly three literalswith a set of clauses each having exactly three literals. (Recall th<strong>at</strong> a literalcan be a variable such as x, or the neg<strong>at</strong>ion of a variable such as x.) LetC i = x 1 + x 2 + ... + x j where x 1 , ..., x j are literals.1. j = 1, so C i = x 1 . Replace C i with C ′ i :(x 1 + y + z) · (x 1 + y + z) · (x 1 + y + z) · (x 1 + y + z)where y <strong>and</strong> z are variables not appearing in E. Clearly, C i ′ is s<strong>at</strong>isfiableif <strong>and</strong> only if (x 1 ) is s<strong>at</strong>isfiable, meaning th<strong>at</strong> x 1 is true.2. J = 2, so C i = (x 1 + x 2 ). Replace C i with(x 1 + x 2 + z) · (x 1 + x 2 + z)where z is a new variable not appearing in E. This new pair of clausesis s<strong>at</strong>isfiable if <strong>and</strong> only if (x 1 + x 2 ) is s<strong>at</strong>isfiable, th<strong>at</strong> is, either x 1 orx 2 must be true.3. j > 3. Replace C i = (x 1 + x 2 + · · · + x j ) with(x 1 + x 2 + z 1 ) · (x 3 + z 1 + z 2 ) · (x 4 + z 2 + z 3 ) · ...·(x j−2 + z j−4 + z j−3 ) · (x j−1 + x j + z j−3 )where z 1 , ..., z j−3 are new variables.After appropri<strong>at</strong>e replacements have been made for each C i , a Booleanexpression results th<strong>at</strong> is an instance of 3 SAT. Each replacement is s<strong>at</strong>isfiableif <strong>and</strong> only if the original clause is s<strong>at</strong>isfiable. The reduction is clearlypolynomial time.For the first two cases it is fairly easy to see th<strong>at</strong> the original clauseis s<strong>at</strong>isfiable if <strong>and</strong> only if the resulting clauses are s<strong>at</strong>isfiable. For thecase were we replaced a clause with more than three literals, consider thefollowing.1. If E is s<strong>at</strong>isfiable, then E ′ is s<strong>at</strong>isfiable: Assume x m is assignedtrue. Then assign z t , t ≤ m − 2 as true <strong>and</strong> z k , t ≥ m − 1 asfalse. Then all clauses in Case (3) are s<strong>at</strong>isfied.2. If x 1 , x 2 , ..., x j are all false, then z 1 , z 2 , ..., z j−3 are all true. Butthen (x j−1 + x j−2 + z j−3 ) is false.✷Next we define the problem VERTEX COVER for use in further examples.VERTEX COVER:Input: A graph G <strong>and</strong> an integer k.Output: YES if there is a subset S of the vertices in G of size k or less suchth<strong>at</strong> every edge of G has <strong>at</strong> least one of its endpoints in S, <strong>and</strong> NO otherwise.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!