Attic › Computer science › NP (complexity)
NP is the class of problems whose answers are quick to verify
In computer science, NP is a complexity class of problems. A problem is in NP if a computer can quickly verify a proposed solution, even when it is very slow to find that solution from scratch.
NP classifies decision problems, which are questions with a "yes" or "no" answer. In computational complexity theory, "quick" means the time complexity—the number of steps the computer takes—grows at most as a power of the input size n, such as n² or n³. This is called polynomial time.
For a problem in NP, whenever the true answer is "yes", there is a piece of evidence called a certificate that proves it. A computer can check this certificate in polynomial time:
1. Take the problem input and the certificate.
2. Run a verification algorithm on them.
3. If the certificate is valid, the algorithm confirms the "yes" answer in polynomial time.
Sudoku is an example of an NP problem. If someone gives you a blank n × n grid and asks, "Does this puzzle have a valid solution?", it can take a long time to find the answer. However, if they give you a completed grid as a certificate, you can quickly check each row, column, and box to verify that the answer is "yes".
Integer factorization can also be framed as an NP problem. If you ask, "Does the number 5,893 have a prime factor smaller than 80?", finding the answer by division takes time. But if someone gives you the certificate "71", you only need to divide 5,893 by 71 once to see that the remainder is 0 and verify that the answer is "yes".
Next: A nondeterministic machine solves NP problems quickly by guessing the right path
Fact-checked against NP (complexity) on Wikipedia
Part of the Computer science syllabus: Computational Complexity
See it on the timeline of Computer science