NP-Completeness General Problems, Input Size and Time Complexity

NP-Completeness General Problems, Input Size and Time Complexity

NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979. Young CS 331 NP-Completeness 1 D&A of Algo. General Problems, Input Size and Time Complexity • Time complexity of algorithms : polynomial time algorithm ("efficient algorithm") v.s. exponential time algorithm ("inefficient algorithm") f(n) \ n 10 30 50 n 0.00001 sec 0.00003 sec 0.00005 sec n5 0.1 sec 24.3 sec 5.2 mins 2n 0.001 sec 17.9 mins 35.7 yrs Young CS 331 NP-Completeness 2 D&A of Algo. 1 “Hard” and “easy’ Problems • Sometimes the dividing line between “easy” and “hard” problems is a fine one. For example – Find the shortest path in a graph from X to Y. (easy) – Find the longest path in a graph from X to Y. (with no cycles) (hard) • View another way – as “yes/no” problems – Is there a simple path from X to Y with weight <= M? (easy) – Is there a simple path from X to Y with weight >= M? (hard) – First problem can be solved in polynomial time. – All known algorithms for the second problem (could) take exponential time . Young CS 331 NP-Completeness 3 D&A of Algo. • Decision problem: The solution to the problem is "yes" or "no". Most optimization problems can be phrased as decision problems (still have the same time complexity). Example : Assume we have a decision algorithm X for 0/1 Knapsack problem with capacity M, i.e. Algorithm X returns “Yes” or “No” to the question “Is there a solution with profit P subject to knapsack capacity M?” Young CS 331 NP-Completeness 4 D&A of Algo. 2 We can repeatedly run algorithm X for various profits(P values) to find an optimal solution. Example : Use binary search to get the optimal profit, maximum of lg pi runs. (where M is the capacity of the knapsack optimization problem) Min Bound Optimal Profit Max Bound Search for the optimal solution 0 pi |___________________|_________________| Young CS 331 NP-Completeness 5 D&A of Algo. The Classes of P and NP • The class P and Deterministic Turing Machine • Given a decision problem X, if there is a polynomial time Deterministic Turing Machine program that solves X, then X is belong to P • Informally, there is a polynomial time algorithm to solve the problem Young CS 331 NP-Completeness 6 D&A of Algo. 3 • The class NP and Non-deterministic Turing Machine • Given a decision problem X. If there is a polynomial time Non-deterministic Turing machine program that solves X, then X belongs to NP • Given a decision problem X. For every instance I of X, (a) guess solution S for I, and (b) check “is S a solution to I?” If (a) and (b) can be done in polynomial time, then X belongs to NP. Young CS 331 NP-Completeness 7 D&A of Algo. • Obvious : P NP, i.e. A NP (decision) problem in P does not need “guess solution”. The correct solution can be P computed in polynomial time. • Some problems which are in NP, but may not in P : • 0/1 Knapsack Problem • PARTITION Problem : Given a finite set of positive integers Z. Question : Is there a subset Z' of Z such that Sum of all numbers in Z' = Sum of all numbers in Z-Z' ? i.e. Z' = (Z-Z') Young CS 331 NP-Completeness 8 D&A of Algo. 4 • One of the most important open problem in theoretical compute science : Is P=NP ? Most likely “No”. Currently, there are many known (decision) problems in NP, and there is no solution to show anyone of them in P. Young CS 331 NP-Completeness 9 D&A of Algo. NP-Complete Problems • Stephen Cook introduced the notion of NP-Complete Problems. – This makes the problem “P = NP ?” much more interesting to study. • The following are several important things presented by Cook : Young CS 331 NP-Completeness 10 D&A of Algo. 5 1. Polynomial Transformation (" ") • L1 L2 : There is a polynomial time transformation that transforms arbitrary instance of L1 to some instance of L2. • If L1 L2 then L2 is in P implies L1 is in P (or L1 is not in P implies L2 is not in P) • If L1 L2 and L2 L3 then L1 L3 Young CS 331 NP-Completeness 11 D&A of Algo. 2. Focus on the class of NP – decision problems only. Many intractable problems, when phrased as decision problems, belong to this class. 3. L is NP-Complete if (#1) L NP & (#2) for all other L' NP, L' L • If an NP-complete problem can be solved in polynomial time then all problems in NP can be solved in polynomial time. • If a problem in NP cannot be solved in polynomial time then all problems in NP-complete cannot be solved in polynomial time. L • Note that an NP-complete problem is one of those hardest problems in NP. 4. L is NP-Hard if (#2 of NP-Complete) for all other L' NP, L' L • Note that an NP-Hard problem is a problem which is as hard as an NP NP-Complete problem and it’s not necessary a decision problem. 5. Young CS 331 NP-Completeness 12 D&A of Algo. 6 • So, if an NP-complete problem is in P then P=NP • if P != NP then all NP-complete problems are in NP-P 4. Question : How can we obtain the first NP-complete problem L? Cook Theorem : SATISFIABILITY is NP- Complete. (The first NP-Complete problem) Instance : Given a set of variables, U, and a collection of clauses, C, over U. Question : Is there a truth assignment for U that satisfies all clauses in C? Young CS 331 NP-Completeness 13 D&A of Algo. Example : U = {x1, x2} C1 = {(x1, ¬ x2), (¬ x1, x2)} = (x1 OR ¬ x2) AND (¬ x1 OR x2) if x1 = x2 = True C1 = True C2 = (x1, x2) (x1, ¬ x2) (¬ x1) not satisfiable “¬ xi ” = “not xi ” “OR” = “logical or ” “AND” = “logical and ” This problem is also called “CNF-Satisfiability” since the expression is in CNF – Conjunctive Normal Form (the product of sums). Young CS 331 NP-Completeness 14 D&A of Algo. 7 • With the Cook Theorem, we have the following property : Lemma : If L1 and L2 belong to NP, L1 is NP-complete, and L1 L2 then L2 is NP-complete. i.e. L1, L2 NP and for all other L' NP, L' L1 and L1 L2 L' L2 Young CS 331 NP-Completeness 15 D&A of Algo. • So now, to prove a (decision) problem L to be NP-complete, we need to • show L is in NP • select a known NP-complete problem L' • construct a polynomial time transformation f from L' to L • prove the correctness of f (i.e. L’ has a solution if and only if L has a solution) and that f is a polynomial transformation Young CS 331 NP-Completeness 16 D&A of Algo. 8 • P: (Decision) problems solvable by deterministic algorithms in polynomial time • NP: (Decision) problems solved by non-deterministic algorithms in polynomial time • A group of (decision) problems, including all of the ones we have NP-Complete discussed (Satisfiability, 0/1 Knapsack, Longest Path, Partition) have an additional important NP property: If any of them can be solved in P polynomial time, then they all can! • These problems are called NP-complete problems. Young CS 331 NP-Completeness 17 D&A of Algo. 9.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us