ArticleslgStudy

mathematics

NP-completeness

NP-completeness is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand NP-completeness rather than just read about it. In short: In computational complexity theory, NP-complete problems are the hardest of the problems to which solutions can be verified quickly. Somewhat more precisely, a problem is NP-complete when: It is a decision problem, meaning that for any input to the problem, the output is either "yes" or "no".

NP-completeness — main illustration
NP-completeness — illustration

Key takeaways

  • NP-completeness belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect NP-completeness to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of NP-completeness from memory before moving on to harder problems.

Reference excerpt

In computational complexity theory, NP-complete problems are the hardest of the problems to which solutions can be verified quickly. Somewhat more precisely, a problem is NP-complete when:

It is a decision problem, meaning that for any input to the problem, the output is either "yes" or "no". Each input to the problem is associated with a collection of short (polynomial size) solutions, which might or might not validly solve the input. The output is "yes" when at least one of these solutions is valid, and "no" when none of them are. The validity of each solution can be verified quickly (namely, in polynomial time), and a brute-force search algorithm can find a valid solution (if one exists) by trying all possible solutions. The problem can be used to simulate every other problem for which we can verify quickly that a solution is valid. Hence, if we could find valid solutions of some NP-complete problem quickly (when they exist), we could quickly find valid solutions for every other problem in which a given solution can be easily verified. Problems that meet the first three criteria belong to the class NP, which is short for "nondeterministic polynomial-time". In this name, "nondeterministic" refers to nondeterministic Turing machines, a way of mathematically formalizing the idea of a brute-force search algorithm. Polynomial time refers to an amount of time that is considered "quick" for a deterministic algorithm to check a single solution, or for a nondeterministic Turing machine to perform the whole search. A problem that is in NP and also meets the fourth criterion is said to be "NP-complete". The term "complete" refers to the property of being able to simulate everything in the same complexity class: If some NP-complete problem has a polynomial-time algorithm, all problems in NP do. The set of NP-complete problems is often denoted by NP-C or NPC. Although a solution to an NP-complete problem can be verified "quickly", there is no known way to find a solution quickly. That is, the time required to solve the problem using any currently known algorithm increases rapidly 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 fundamental unsolved problems in computer science today. While a method for computing the solutions to NP-complete problems quickly remains undiscovered, computer scientists and programmers still frequently encounter NP-complete problems. NP-complete problems are often addressed by using heuristic methods and approximation algorithms.

Formal definition and related complexity classes

A decision problem C {\displaystyle \scriptstyle C} is NP-complete if:

C {\displaystyle \scriptstyle C} is in NP, and Every problem in NP is reducible to C {\displaystyle \scriptstyle C} in polynomial time.

C {\displaystyle \scriptstyle C} can be shown to be in NP by demonstrating that a candidate solution to C {\displaystyle \scriptstyle C} can be verified in polynomial time. A decision problem that is solvable in polynomial time belongs to the class P. All problems in P are necessarily in NP. However, it has not been proved that the class NP is actually larger than P. In other words, it is not yet known whether there exist problems in NP that are not in P. The question of whether the classes P and NP are equal or not is known as the P versus NP problem. A consequence of the definition of NP-completeness is that if we had a polynomial-time algorithm (on a UTM, or any other Turing-equivalent abstract machine) for C {\displaystyle \scriptstyle C} , we could solve all problems in NP in polynomial time. A problem is said to be NP-hard if everything in NP can be transformed in polynomial time into it even though it may not be in NP. A problem is NP-complete if it is both in NP and NP-hard. The NP-complete problems are thus, in a sense, the hardest problems in NP.

Known NP-complete problems

The Cook–Levin theorem states that the Boolean satisfiability problem is NP-complete, establishing for the first time that such problems do exist. In 1972, Richard Karp proved that several other problems were also NP-complete (see Karp's 21 NP-complete problems); thus, there is a class of NP-complete problems, besides Boolean satisfiability. Since these original results, thousands of other problems have been shown to be NP-complete by reductions from other problems previously shown to be NP-complete; many of these problems are collected in Garey & Johnson (1979). The easiest way to prove that some new problem is NP-complete is first to prove that it is in NP, and then to reduce some known NP-complete problem to it. Therefore, it is useful to know a variety of NP-complete problems. The list below contains some well-known problems that are NP-complete when expressed as decision problems.

… excerpt ends here. Continue reading the full article.

Illustrations

NP-completeness: It can be difficult to find a valid solution to a Sudoku puzzle, but once a solution has been found its validity can be verified easily. It is NP-complete to determine whether an n × n Sudoku has a valid solution.[1]
It can be difficult to find a valid solution to a Sudoku puzzle, but once a solution has been found its validity can be verified easily. It is NP-complete to determine whether an n × n Sudoku has a valid solution.[1]
NP-completeness: Euler diagram for P, NP, NP-complete, and NP-hard sets of problems.  The left side is valid under the assumption that P≠NP, while the right side is valid under the assumption that P=NP (except that the empty language and its complement are never NP-complete, and in general, not every problem in P or NP is NP-complete).
Euler diagram for P, NP, NP-complete, and NP-hard sets of problems. The left side is valid under the assumption that P≠NP, while the right side is valid under the assumption that P=NP (except that the empty language and its complement are never NP-complete, and in general, not every problem in P or NP is NP-complete).
NP-completeness: Some NP-complete problems, indicating the reductions typically used to prove their NP-completeness
Some NP-complete problems, indicating the reductions typically used to prove their NP-completeness

Worked examples

Example 1 — a first encounter with NP-completeness

Start with the simplest possible case. Write down what NP-completeness claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to NP-completeness before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about NP-completeness ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of NP-completeness

In research
NP-completeness appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses NP-completeness in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
NP-completeness is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1971 in computing, Complexity classes, Mathematical optimization, so understanding it makes those chapters shorter.
In everyday life
Look for NP-completeness outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study NP-completeness in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what NP-completeness means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain NP-completeness out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is NP-completeness in simple terms?

In computational complexity theory, NP-complete problems are the hardest of the problems to which solutions can be verified quickly. Somewhat more precisely, a problem is NP-complete when: It is a decision problem, meaning that for any input to the problem, the output is either "yes" or "no".

Why does NP-completeness matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study NP-completeness?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on NP-completeness.

Tags

  • 1971 in computing
  • Complexity classes
  • Mathematical optimization
  • NP-complete problems

Keep exploring