Advanced Topic 36 of 51 Theory & Discrete Math
Class NP
Problems whose solutions can be verified quickly.
How it works
Class NP consists of decision problems for which a proposed solution can be verified in polynomial time by a deterministic algorithm, equivalently solvable in polynomial time by a nondeterministic Turing machine. Examples include satisfiability, graph coloring, clique, subset sum, the Hamiltonian cycle and factoring in its decision form. Every problem in P is in NP, and the famous open question is whether the reverse holds. A certificate is the evidence, such as an assignment or a path, that the verifier checks.
Step-by-step walkthrough
- NP problems have solutions that can be checked in polynomial time.
- Sudoku: given a filled grid, checking is easy.
- Solving from scratch may take much longer, nobody knows.
- Every problem in P is also in NP.
Where it is used
NP captures many practical search and optimization problems in scheduling, routing, design and verification. Solvers use heuristics, SAT and SMT engines and approximation.
Common pitfall
NP does not stand for not polynomial but nondeterministic polynomial time. A problem being in NP says nothing about being hard; it includes all of P. Checking a certificate is easy, finding one may not be. Complement problems, such as proving unsatisfiability, may not be in NP, which leads to the class co-NP. Always specify the decision version.
Where it fits in the course
Class NP is topic 36 of 51 in Theory & Discrete Math, rated Advanced. It follows Class P. The next topic is NP-Completeness.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Theory & Discrete Math quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Theory & Discrete Math quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Class NP?
Where do people use Class NP?
What is the most common mistake with Class NP?
What should I learn before this topic?
How can I practice it?
Is Class NP hard to learn?
How long does it take to learn Class NP?
Which topics are related to Class NP?
What should I study after Class NP?
Related topics
- Class P (Theory & Discrete Math)
- NP-Completeness (Theory & Discrete Math)
- Complexity Classes (Theory & Discrete Math)
- Cook-Levin Theorem (Theory & Discrete Math)