150 likes | 241 Views
NP-Complete Problems. NP and P. What is NP?
E N D
NP and P • What is NP? • NP is the set of all decision problems (question with yes-or-no answer) for which the 'yes'-answers can be verified in polynomial time (O(n^k) where n is the problem size, and k is a constant) by a deterministic Turing machine. Polynomial time is sometimes used as the definition of fast or quickly. • What is P? • P is the set of all decision problems which can be solved in polynomial time by a deterministic Turing machine. Since it can solve in polynomial time, it can also be verified in polynomial time. Therefore P is a subset of NP.
Class of “P” Problems • Class P consists of (decision) problems that are solvable in polynomial time • Polynomial-time algorithms • Worst-case running time is O(nk), for some constant k • Examples of polynomial time: • O(n2), O(n3), O(1), O(n lg n) • Examples of non-polynomial time: • O(2n), O(nn), O(n!)
Class of “NP” Problems • Class NP consists of problems that could be solved by NP algorithms • i.e., verifiable in polynomial time • If we were given a “certificate” of a solution, we could verify that the certificate is correct in time polynomial to the size of the input • Warning: NP does not mean “non-polynomial”
NP-Complete • What is NP-Complete? • A problem x that is in NP is also in NP-Complete if and only if every other problem in NP can be quickly (ie. in polynomial time) transformed into x. In other words: • x is in NP, and • Every problem in NP is reducible to x • So what makes NP-Complete so interesting is that if any one of the NP-Complete problems was to be solved quickly then all NP problems can be solved quickly
NP-Hard • What is NP-Hard? • NP-Hard are problems that are at least as hard as the hardest problems in NP. Note that NP-Complete problems are also NP-hard. However not all NP-hard problems are NP (or even a decision problem), despite having 'NP' as a prefix. That is the NP in NP-hard does not mean 'non-deterministic polynomial time'. Yes this is confusing but its usage is entrenched and unlikely to change.
Tractable/Intractable Problems • Problems in P are also called tractable • Problems not in P are intractable or unsolvable • Can be solved in reasonable time only for small inputs • Or, can not be solved at all • Are non-polynomial algorithms always worst than polynomial algorithms? - n1,000,000 is technically tractable, but really impossible - nlog log log n is technically intractable, but easy
Reductions yes yes f Problem B no no Problem A • Reduction is a way of saying that one problem is “easier” than another. • We say that problem A is easier than problem B, (i.e., we write “A B”) if we can solve A using the algorithm that solves B. • Idea:transform the inputs of A to inputs of B
Polynomial Reductions • Given two problems A, B, we say that A is polynomially reducible to B (A p B) if: • There exists a function f that converts the input of A to inputs of B in polynomial time • A(i) = YES B(f(i)) = YES
Vertex Cover(VC) • Given a graph and an integer k, is there a collection of k vertices such that each edge is connected to one of the vertices in the collection?