NPcompleteness
This article may be confusing or unclear to readers. (July 2012) (Learn how and when to remove this template message)

In computational complexity theory, an NPcomplete decision problem is one belonging to both the NP and the NPhard complexity classes. In this context, NP stands for "nondeterministic polynomial time". The set of NPcomplete problems is often denoted by NPC or NPC.
Although any given solution to an NPcomplete problem can be verified quickly (in polynomial time), there is no known efficient way to locate a solution in the first place; indeed, the most notable characteristic of NPcomplete problems is that no fast solution to them is known. That is, the time required to solve the problem using any currently known algorithm increases very quickly as the size of the problem grows. As a consequence, determining whether it is possible to solve these problems quickly, called the P versus NP problem, is one of the principal unsolved problems in computer science today.
While a method for computing the solutions to NPcomplete problems using a reasonable amount of time remains undiscovered, computer scientists and programmers still frequently encounter NPcomplete problems. NPcomplete problems are often addressed by using heuristic methods and approximation algorithms.
Contents
Overview
NPcomplete problems are in NP, the set of all decision problems whose solutions can be verified in polynomial time; NP may be equivalently defined as the set of decision problems that can be solved in polynomial time on a nondeterministic Turing machine. A problem p in NP is NPcomplete if every other problem in NP can be transformed (or reduced) into p in polynomial time.
NPcomplete problems are studied because the ability to quickly verify solutions to a problem (NP) seems to correlate with the ability to quickly solve that problem (P). It is not known whether every problem in NP can be quickly solved—this is called the P versus NP problem. But if any NPcomplete problem can be solved quickly, then every problem in NP can, because the definition of an NPcomplete problem states that every problem in NP must be quickly reducible to every NPcomplete problem (that is, it can be reduced in polynomial time). Because of this, it is often said that NPcomplete problems are harder or more difficult than NP problems in general.
Formal definition
A decision problem is NPcomplete if:
 is in NP, and
 Every problem in NP is reducible to in polynomial time.^{[1]}
can be shown to be in NP by demonstrating that a candidate solution to can be verified in polynomial time.
Note that a problem satisfying condition 2 is said to be NPhard, whether or not it satisfies condition 1.^{[2]}
A consequence of this definition is that if we had a polynomial time algorithm (on a UTM, or any other Turingequivalent abstract machine) for , we could solve all problems in NP in polynomial time.
Background
The concept of NPcompleteness was introduced in 1971 (see Cook–Levin theorem), though the term NPcomplete was introduced later. At 1971 STOC conference, there was a fierce debate among the computer scientists about whether NPcomplete problems could be solved in polynomial time on a deterministic Turing machine. John Hopcroft brought everyone at the conference to a consensus that the question of whether NPcomplete problems are solvable in polynomial time should be put off to be solved at some later date, since nobody had any formal proofs for their claims one way or the other. This is known as the question of whether P=NP.
Nobody has yet been able to determine conclusively whether NPcomplete problems are in fact solvable in polynomial time, making this one of the great unsolved problems of mathematics. The Clay Mathematics Institute is offering a US $1 million reward to anyone who has a formal proof that P=NP or that P≠NP.
Cook–Levin theorem states that the Boolean satisfiability problem is NPcomplete (a simpler, but still highly technical proof of this is available). In 1972, Richard Karp proved that several other problems were also NPcomplete (see Karp's 21 NPcomplete problems); thus there is a class of NPcomplete problems (besides the Boolean satisfiability problem). Since the original results, thousands of other problems have been shown to be NPcomplete by reductions from other problems previously shown to be NPcomplete; many of these problems are collected in Garey and Johnson's 1979 book Computers and Intractability: A Guide to the Theory of NPCompleteness.^{[3]} For more details refer to Introduction to the Design and Analysis of Algorithms by Anany Levitin.
NPcomplete problems
An interesting example is the graph isomorphism problem, the graph theory problem of determining whether a graph isomorphism exists between two graphs. Two graphs are isomorphic if one can be transformed into the other simply by renaming vertices. Consider these two problems:
 Graph Isomorphism: Is graph G_{1} isomorphic to graph G_{2}?
 Subgraph Isomorphism: Is graph G_{1} isomorphic to a subgraph of graph G_{2}?
The Subgraph Isomorphism problem is NPcomplete. The graph isomorphism problem is suspected to be neither in P nor NPcomplete, though it is in NP. This is an example of a problem that is thought to be hard, but is not thought to be NPcomplete.
The easiest way to prove that some new problem is NPcomplete is first to prove that it is in NP, and then to reduce some known NPcomplete problem to it. Therefore, it is useful to know a variety of NPcomplete problems. The list below contains some wellknown problems that are NPcomplete when expressed as decision problems.
To the right is a diagram of some of the problems and the reductions typically used to prove their NPcompleteness. In this diagram, an arrow from one problem to another indicates the direction of the reduction. Note that this diagram is misleading as a description of the mathematical relationship between these problems, as there exists a polynomialtime reduction between any two NPcomplete problems; but it indicates where demonstrating this polynomialtime reduction has been easiest.
There is often only a small difference between a problem in P and an NPcomplete problem. For example, the 3satisfiability problem, a restriction of the boolean satisfiability problem, remains NPcomplete, whereas the slightly more restricted 2satisfiability problem is in P (specifically, NLcomplete), and the slightly more general max. 2sat. problem is again NPcomplete. Determining whether a graph can be colored with 2 colors is in P, but with 3 colors is NPcomplete, even when restricted to planar graphs. Determining if a graph is a cycle or is bipartite is very easy (in L), but finding a maximum bipartite or a maximum cycle subgraph is NPcomplete. A solution of the knapsack problem within any fixed percentage of the optimal solution can be computed in polynomial time, but finding the optimal solution is NPcomplete.
Solving NPcomplete problems
At present, all known algorithms for NPcomplete problems require time that is superpolynomial in the input size, and it is unknown whether there are any faster algorithms.
The following techniques can be applied to solve computational problems in general, and they often give rise to substantially faster algorithms:
 Approximation: Instead of searching for an optimal solution, search for a solution that is at most a factor from an optimal one.
 Randomization: Use randomness to get a faster average running time, and allow the algorithm to fail with some small probability. Note: The Monte Carlo method is not an example of an efficient algorithm in this specific sense, although evolutionary approaches like Genetic algorithms may be.
 Restriction: By restricting the structure of the input (e.g., to planar graphs), faster algorithms are usually possible.
 Parameterization: Often there are fast algorithms if certain parameters of the input are fixed.
 Heuristic: An algorithm that works "reasonably well" in many cases, but for which there is no proof that it is both always fast and always produces a good result. Metaheuristic approaches are often used.
One example of a heuristic algorithm is a suboptimal greedy coloring algorithm used for graph coloring during the register allocation phase of some compilers, a technique called graphcoloring global register allocation. Each vertex is a variable, edges are drawn between variables which are being used at the same time, and colors indicate the register assigned to each variable. Because most RISC machines have a fairly large number of generalpurpose registers, even a heuristic approach is effective for this application.
Completeness under different types of reduction
In the definition of NPcomplete given above, the term reduction was used in the technical meaning of a polynomialtime manyone reduction.
Another type of reduction is polynomialtime Turing reduction. A problem is polynomialtime Turingreducible to a problem if, given a subroutine that solves in polynomial time, one could write a program that calls this subroutine and solves in polynomial time. This contrasts with manyone reducibility, which has the restriction that the program can only call the subroutine once, and the return value of the subroutine must be the return value of the program.
If one defines the analogue to NPcomplete with Turing reductions instead of manyone reductions, the resulting set of problems won't be smaller than NPcomplete; it is an open question whether it will be any larger.
Another type of reduction that is also often used to define NPcompleteness is the logarithmicspace manyone reduction which is a manyone reduction that can be computed with only a logarithmic amount of space. Since every computation that can be done in logarithmic space can also be done in polynomial time it follows that if there is a logarithmicspace manyone reduction then there is also a polynomialtime manyone reduction. This type of reduction is more refined than the more usual polynomialtime manyone reductions and it allows us to distinguish more classes such as Pcomplete. Whether under these types of reductions the definition of NPcomplete changes is still an open problem. All currently known NPcomplete problems are NPcomplete under log space reductions. Indeed, all currently known NPcomplete problems remain NPcomplete even under much weaker reductions.^{[4]} It is known, however, that AC^{0} reductions define a strictly smaller class than polynomialtime reductions.^{[5]}
Naming
According to Donald Knuth, the name "NPcomplete" was popularized by Alfred Aho, John Hopcroft and Jeffrey Ullman in their celebrated textbook "The Design and Analysis of Computer Algorithms". He reports that they introduced the change in the galley proofs for the book (from "polynomiallycomplete"), in accordance with the results of a poll he had conducted of the theoretical computer science community.^{[6]} Other suggestions made in the poll^{[7]} included "Herculean", "formidable", Steiglitz's "hardboiled" in honor of Cook, and Shen Lin's acronym "PET", which stood for "probably exponential time", but depending on which way the P versus NP problem went, could stand for "provably exponential time" or "previously exponential time".^{[8]}
Common misconceptions
The following misconceptions are frequent.^{[9]}
 "NPcomplete problems are the most difficult known problems." Since NPcomplete problems are in NP, their running time is at most exponential. However, some problems provably require more time, for example Presburger arithmetic.
 "NPcomplete problems are difficult because there are so many different solutions." On the one hand, there are many problems that have a solution space just as large, but can be solved in polynomial time (for example minimum spanning tree). On the other hand, there are NPproblems with at most one solution that are NPhard under randomized polynomialtime reduction (see Valiant–Vazirani theorem).
 "Solving NPcomplete problems requires exponential time." First, this would imply P ≠ NP, which is still an unsolved question. Further, some NPcomplete problems actually have algorithms running in superpolynomial, but subexponential time such as O(2^{√n}n). For example, the independent set and dominating set problems are NPcomplete when restricted to planar graphs, but can be solved in subexponential time on planar graphs using the planar separator theorem.^{[10]}
 "All instances of an NPcomplete problem are difficult." Often some instances, or even most instances, may be easy to solve within polynomial time. However, unless P=NP, any polynomialtime algorithm must asymptotically be wrong on more than polynomially many of the exponentially many inputs of a certain size.^{[11]}
 "If P=NP, all cryptographic ciphers can be broken." A polynomialtime problem can be very difficult to solve in practice if the polynomial's degree or constants are large enough. For example, ciphers with a fixed key length, such as Advanced Encryption Standard, can all be broken in constant time (and are thus already in P), though with current technology that constant may exceed the age of the universe.
Properties
Viewing a decision problem as a formal language in some fixed encoding, the set NPC of all NPcomplete problems is not closed under:
It is not known whether NPC is closed under complementation, since NPC=coNPC if and only if NP=coNP, and whether NP=coNP is an open question.^{[12]}
See also
 Almost complete
 Gadget (computer science)
 Ladner's theorem
 List of NPcomplete problems
 NPhard
 P = NP problem
 Strongly NPcomplete
References
Citations
 ^ J. van Leeuwen (1998). Handbook of Theoretical Computer Science. Elsevier. p. 84. ISBN 0262720140.
 ^ J. van Leeuwen (1998). Handbook of Theoretical Computer Science. Elsevier. p. 80. ISBN 0262720140.
 ^ Garey, Michael R.; Johnson, D. S. (1979). Victor Klee, ed. Computers and Intractability: A Guide to the Theory of NPCompleteness. A Series of Books in the Mathematical Sciences. San Francisco, Calif.: W. H. Freeman and Co. pp. x+338. ISBN 0716710455. MR 0519066.
 ^ Agrawal, M.; Allender, E.; Rudich, Steven (1998). "Reductions in Circuit Complexity: An Isomorphism Theorem and a Gap Theorem". Journal of Computer and System Sciences. Academic Press. 57 (2): 127–143. doi:10.1006/jcss.1998.1583. ISSN 10902724.
 ^ Agrawal, M.; Allender, E.; Impagliazzo, R.; Pitassi, T.; Rudich, Steven (2001). "Reducing the complexity of reductions". Computational Complexity. Birkhäuser Basel. 10 (2): 117–138. doi:10.1007/s0003700181911. ISSN 10163328
 ^ Don Knuth, Tracy Larrabee, and Paul M. Roberts, Mathematical Writing § 25, MAA Notes No. 14, MAA, 1989 (also Stanford Technical Report, 1987).
 ^ Knuth, D. F. (1974). "A terminological proposal". SIGACT News. 6 (1): 12–18. doi:10.1145/1811129.1811130. Retrieved 20100828.
 ^ See the poll, or [1].
 ^ Ball, Philip. "DNA computer helps travelling salesman". doi:10.1038/news00011310.
 ^ Bern (1990); Deĭneko, Klinz & Woeginger (2006); Dorn et al. (2005); Lipton & Tarjan (1980).
 ^ Hemaspaandra, L. A.; Williams, R. (2012). "SIGACT News Complexity Theory Column 76". ACM SIGACT News. 43 (4): 70. doi:10.1145/2421119.2421135.

^ Talbot, John; Welsh, D. J. A. (2006), Complexity and Cryptography: An Introduction, Cambridge University Press, p. 57, ISBN 9780521617710,
The question of whether NP and coNP are equal is probably the second most important open problem in complexity theory, after the P versus NP question.
Sources
 Garey, M.R.; Johnson, D.S. (1979). Computers and Intractability: A Guide to the Theory of NPCompleteness. New York: W.H. Freeman. ISBN 0716710455. This book is a classic, developing the theory, then cataloguing many NPComplete problems.
 Cook, S.A. (1971). "The complexity of theorem proving procedures". Proceedings, Third Annual ACM Symposium on the Theory of Computing, ACM, New York. pp. 151–158. doi:10.1145/800157.805047.
 Dunne, P.E. "An annotated list of selected NPcomplete problems". COMP202, Dept. of Computer Science, University of Liverpool. Retrieved 20080621.
 Crescenzi, P.; Kann, V.; Halldórsson, M.; Karpinski, M.; Woeginger, G. "A compendium of NP optimization problems". KTH NADA, Stockholm. Retrieved 20080621.
 Dahlke, K. "NPcomplete problems". Math Reference Project. Retrieved 20080621.
 Karlsson, R. "Lecture 8: NPcomplete problems" (PDF). Dept. of Computer Science, Lund University, Sweden. Archived from the original (PDF) on April 19, 2009. Retrieved 20080621.
 Sun, H.M. "The theory of NPcompleteness" (PPT). Information Security Laboratory, Dept. of Computer Science, National Tsing Hua University, Hsinchu City, Taiwan. Retrieved 20080621.
 Jiang, J.R. "The theory of NPcompleteness" (PPT). Dept. of Computer Science and Information Engineering, National Central University, Jhongli City, Taiwan. Retrieved 20080621.
 Cormen, T.H.; Leiserson, C.E.; Rivest, R.L.; Stein, C. (2001). "Chapter 34: NP–Completeness". Introduction to Algorithms (2nd ed.). MIT Press and McGrawHill. pp. 966–1021. ISBN 0262032937.
 Sipser, M. (1997). "Sections 7.4–7.5 (NPcompleteness, Additional NPcomplete Problems)". Introduction to the Theory of Computation. PWS Publishing. pp. 248–271. ISBN 053494728X.
 Papadimitriou, C. (1994). "Chapter 9 (NPcomplete problems)". Computational Complexity (1st ed.). Addison Wesley. pp. 181–218. ISBN 0201530821.
 Computational Complexity of Games and Puzzles
 Tetris is Hard, Even to Approximate
 Minesweeper is NPcomplete!
 Bern, Marshall (1990). "Faster exact algorithms for Steiner trees in planar networks". Networks. 20 (1): 109–120. doi:10.1002/net.3230200110.
 Deĭneko, Vladimir G.; Klinz, Bettina; Woeginger, Gerhard J. (2006). "Exact algorithms for the Hamiltonian cycle problem in planar graphs". Operations Research Letters. 34 (3): 269–274. doi:10.1016/j.orl.2005.04.013.
 Dorn, Frederic; Penninkx, Eelko; Bodlaender, Hans L. author3link = Hans L. Bodlaender; Fomin, Fedor V. (2005). "Efficient Exact Algorithms on Planar Graphs: Exploiting Sphere Cut Branch Decompositions". Proc. 13th European Symposium on Algorithms (ESA '05). Lecture Notes in Computer Science. 3669. SpringerVerlag. pp. 95–106. doi:10.1007/11561071_11. ISBN 9783540291183.
 Lipton, Richard J.; Tarjan, Robert E. (1980). "Applications of a planar separator theorem". SIAM Journal on Computing. 9 (3): 615–627. doi:10.1137/0209046.
Further reading
 Scott Aaronson, NPcomplete Problems and Physical Reality, ACM SIGACT News, Vol. 36, No. 1. (March 2005), pp. 30–52.
 Lance Fortnow, The status of the P versus NP problem, Commun. ACM, Vol. 52, No. 9. (2009), pp. 78–86.