12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

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 575For the first two cases it is fairly easy <strong>to</strong> see that the original clauseis satisfiable if <strong>and</strong> only if the resulting clauses are satisfiable. For thecase were we replaced a clause with more than three literals, consider thefollowing.1. If E is satisfiable, then E ′ is satisfiable: 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 satisfied.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 suchthat every edge of G has at least one of its endpoints in S, <strong>and</strong> NO otherwise.Example 17.2 In this example, we make use of a simple conversion betweentwo graph problems.Theorem 17.2 VERTEX COVER is N P-complete.Proof: Prove that VERTEX COVER is in N P: Simply guess a subse<strong>to</strong>f the graph <strong>and</strong> determine in polynomial time whether that subset is in facta vertex cover of size k or less.Prove that VERTEX COVER is N P-hard: We will assume that K-CLIQUE is already known <strong>to</strong> be N P-complete. (We will see this proof inthe next example. For now, just accept that it is true.)Given that K-CLIQUE is N P-complete, we need <strong>to</strong> find a polynomialtimetransformation from the input <strong>to</strong> K-CLIQUE <strong>to</strong> the input <strong>to</strong> VERTEXCOVER, <strong>and</strong> another polynomial-time transformation from the output forVERTEX COVER <strong>to</strong> the output for K-CLIQUE. This turns out <strong>to</strong> be asimple matter, given the following observation. Consider a graph G <strong>and</strong>a vertex cover S on G. Denote by S ′ the set of vertices in G but not in S.There can be no edge connecting any two vertices in S ′ because, if therewere, then S would not be a vertex cover. Denote by G ′ the inverse graphfor G, that is, the graph formed from the edges not in G. If S is of sizek, then S ′ forms a clique of size n − k in graph G ′ . Thus, we can reduceK-CLIQUE <strong>to</strong> VERTEX COVER simply by converting graph G <strong>to</strong> G ′ , <strong>and</strong>

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

Saved successfully!

Ooh no, something went wrong!