Explainer
Complexity classes explained: P, NP, BQP and beyond
Complexity classes group problems by the resources the best possible algorithm needs: P holds yes-or-no problems solvable in polynomial time, NP those whose answers can be checked in polynomial time, and BQP those a quantum computer can solve efficiently with bounded error.[1][2][3] Whether P equals NP is unsolved, and widely used public-key schemes such as RSA rely on factoring and related problems being hard for classical computers.[4][5][6]
Read big O notation first: this page builds on the difference between polynomial and exponential growth. Afterwards, quantum algorithms shows where quantum speedups come from, and MIP* = RE shows how far complexity theory reaches once entanglement is allowed.
A complexity class is a set of problems that can be solved within the same kind of resource limit, such as polynomial time on an ordinary computer or on a quantum computer.[1][3] The classes let researchers say precisely how hard a problem is, and they explain why some problems are trusted to keep data secure.[5]
Decision problems and polynomial time
Most classes are defined for decision problems, which have a yes-or-no answer. An optimisation problem instead asks for the best solution; the travelling salesman problem asks for the shortest tour, while its decision version asks whether a tour shorter than some fixed amount exists.[7]
“Efficient” usually means polynomial time: the running time is at most a fixed power of the input size, O(n^k). Algorithms that need exponential time grow too fast to expect exact answers in every case.[8]
P, NP and NP-complete
P is the set of decision problems an ordinary computer can solve in polynomial time.[1] NP is the set of decision problems where a claimed “yes” answer can be checked in polynomial time, even if finding it might be much harder.[2] For example, if someone hands you a route that visits every point of a network exactly once, you can check it quickly; but showing that no such route exists does not have to be quick.[9]
NP-complete problems are the hardest problems in NP: a fast algorithm for any one of them could be used to solve all NP problems quickly. Satisfiability (SAT), the travelling salesman, bin packing and knapsack problems are standard examples.[10] The optimisation versions, such as finding the shortest tour, are called NP-hard.[11]
P is the class of languages accepted by a deterministic Turing machine in polynomial time; NP is the class accepted by a nondeterministic Turing machine in polynomial time, equivalently the decision problems with polynomial-time verifiable certificates.[1][2] Membership in NP says nothing about short certificates for “no” instances.[9] A problem is NP-complete if it is in NP and every NP problem reduces to it with at most polynomial overhead; when a decision version is NP-complete, the corresponding optimisation problem is NP-hard.[10][11]
The Clay Mathematics Institute frames the open question this way: if it is easy to check that a solution is correct, is it also easy to find one? Stephen Cook and Leonid Levin formulated it independently in 1971, and it is one of Clay’s unsolved Millennium Prize Problems.[4] Many NP problems seem very hard, but no one has proved that any of them really is.[12]
Randomness: BPP
BPP is the set of problems a computer that can flip coins solves in polynomial time, giving the right answer at least two-thirds of the time. Repeating the run makes the chance of error as small as needed.[13]
Quantum computers: BQP
BQP, bounded-error quantum polynomial time, is the quantum counterpart of BPP: decision problems a quantum computer solves in polynomial time with at most a one-third chance of error. The Complexity Zoo, a reference wiki of complexity classes, says BQP is often identified as the class of problems that are feasible for quantum computers.[3]
What is known about BQP, as summarised in the Complexity Zoo:
- It contains BPP, so a quantum computer can do anything a randomised classical computer can do efficiently.[14]
- It contains factoring and discrete logarithms, through Shor’s algorithms, which take a number of steps that grows only polynomially with the input size.[14][15]
- It is contained in a classical class called PP, which sets a ceiling on what quantum computers can do efficiently.[14]
Factoring and discrete logarithms are generally thought to be hard for classical computers, and cryptosystems have been built on that assumption.[5] NIST’s post-quantum work starts from the consequence: a large quantum computer would break RSA, elliptic-curve and finite-field public-key schemes.[6] See how post-quantum cryptography works.
What is still open
The main relationships between these classes are unproven. Nobody has shown that P differs from NP.[12] For BQP, much of the evidence comes from “oracle” results, which compare classes when they can query a black box. Results listed in the Complexity Zoo show that relative to some oracles BQP falls outside the polynomial hierarchy, and relative to a random oracle NP is not contained in BQP.[16] These results guide intuition, but they do not settle the questions for real computers.[16]
Complexity classes also reach far beyond everyday computing. When a verifier can question several provers who share quantum entanglement, the class of checkable problems becomes as large as RE, which includes problems no computer can solve; that is the MIP* = RE result.[17]
Read next
Next in the crash course
P vs NP explained: the biggest open question in computer science
P vs NP in plain terms: easy to check versus easy to solve, NP-completeness, why encryption depends on the answer, and why a proof is so hard.
Questions readers ask
What is the difference between P and NP?
P is the set of yes-or-no problems a deterministic computer can solve in polynomial time. NP is the set whose "yes" answers can be checked in polynomial time once someone hands you a solution. Nobody has proved whether the two classes are equal.[1][2][4]
What does NP-complete mean?
An NP-complete problem is in NP, and a fast algorithm for it could be used to solve every NP problem quickly. Satisfiability (SAT), the travelling salesman problem, bin packing and knapsack are standard examples in their yes-or-no forms.[10]
Sources
· 17 claims from 8 publishers
Each numbered claim is a statement we checked against the sources listed with it. Tap a number in the text to see its sources in place.
- [1]
P is the class of problems (languages) that a deterministic Turing machine can decide in polynomial time. confirmedas of 2026-11-22
- P (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- [2]
NP is the class of decision problems whose answers can be checked by an algorithm running in time polynomial in the input size; this does not mean an answer can be found quickly, and the name stands for nondeterministic polynomial time. confirmedas of 2026-11-22
- NP (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- NP (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- [3]
The Complexity Zoo defines BQP (bounded-error quantum polynomial time) as the decision problems a quantum computer can solve in polynomial time with at most a one-third probability of error, and says BQP is often identified as the class of problems feasible for quantum computers. reportedas of 2026-11-22
- Complexity Zoo: B (BPP, BQP and related classes) · Complexity Zoo (community wiki) · Secondary source · BQP entry (retrieved 2026-11-22)
- Complexity Zoo: B (BPP, BQP and related classes) · Complexity Zoo (community wiki) · Secondary source · BQP entry (retrieved 2026-11-22)
- [4]
The Clay Mathematics Institute lists P vs NP as an unsolved Millennium Prize Problem and frames it as whether a problem whose solution is easy to check is also easy to solve; Stephen Cook and Leonid Levin formulated it independently in 1971. confirmedas of 2026-11-22
- P vs NP (Millennium Prize Problems) · Clay Mathematics Institute · Primary source · Problem summary (retrieved 2026-11-22)
- P vs NP (Millennium Prize Problems) · Clay Mathematics Institute · Primary source · Overview (retrieved 2026-11-22)
- [5]
Shor's paper describes factoring integers and finding discrete logarithms as problems generally thought to be hard on a classical computer that have been used as the basis of several cryptosystems, and gives efficient randomised algorithms for both on a hypothetical quantum computer. reportedas of 2026-11-22
- Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer · arXiv (author's version of the SIAM Journal on Computing paper, 1997) · Secondary source · 1995-08-30 · Abstract (retrieved 2026-11-22)
- Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer · arXiv (author's version of the SIAM Journal on Computing paper, 1997) · Secondary source · 1995-08-30 · Abstract (retrieved 2026-11-22)
- [6]
NIST's 2016 report on post-quantum cryptography says a large-scale quantum computer would make RSA, elliptic-curve and finite-field public-key schemes no longer secure, because Shor's algorithm efficiently solves the problems they rely on. confirmedas of 2016-04-28
- Report on Post-Quantum Cryptography (NISTIR 8105) · NIST · Primary source · 2016-04-28 (retrieved 2026-11-21)
- Report on Post-Quantum Cryptography (NISTIR 8105) · NIST · Primary source · 2016-04-28 (retrieved 2026-11-21)
- [7]
Complexity classes are usually defined for decision problems, which have a yes-or-no answer; an optimization problem instead asks for the best solution, as in the travelling salesman problem. confirmedas of 2026-11-22
- decision problem (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- decision problem (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Note (retrieved 2026-11-22)
- [8]
Polynomial time means the execution time is at most a polynomial in the problem size, O(n^k) for a constant k; NIST says such algorithms are broadly reasonable to compute, while exponential algorithms grow too fast to expect exact solutions in all cases. confirmedas of 2026-11-22
- polynomial time (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- polynomial time (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Note (retrieved 2026-11-22)
- [9]
For example, a claimed tour of a graph that visits every vertex exactly once (a Hamiltonian cycle) can be checked quickly, but being in NP does not require that a "no" answer can be checked quickly. confirmedas of 2026-11-22
- NP (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Note (retrieved 2026-11-22)
- NP (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Note (retrieved 2026-11-22)
- [10]
A problem is NP-complete if it is in NP and a quick algorithm for it could be used to solve all other NP problems quickly; satisfiability (SAT), the travelling salesman, bin packing and knapsack problems (in their decision versions) are well-known examples. confirmedas of 2026-11-22
- NP-complete (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- NP-complete (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Note (retrieved 2026-11-22)
- [11]
When the decision version of an optimisation problem is NP-complete, the optimisation version is NP-hard; asking whether a tour shorter than k exists is NP-complete, while finding the shortest tour is NP-hard. confirmedas of 2026-11-22
- NP-hard (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- NP-hard (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Note (retrieved 2026-11-22)
- [12]
Clay notes that although problems like these seem very hard, no one has yet proved that any of them really is as hard as it appears. confirmedas of 2026-11-22
- P vs NP (Millennium Prize Problems) · Clay Mathematics Institute · Primary source · Overview (retrieved 2026-11-22)
- [13]
BPP is the class of problems a probabilistic Turing machine can decide in polynomial time, giving the right answer at least two-thirds of the time; repeating the run can make the chance of error as small as wanted. confirmedas of 2026-11-22
- BPP (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Definition (retrieved 2026-11-22)
- BPP (Dictionary of Algorithms and Data Structures) · US National Institute of Standards and Technology · Primary source · Note (retrieved 2026-11-22)
- [14]
According to the Complexity Zoo, BQP contains the factoring and discrete logarithm problems, contains BPP, and is contained in the class PP. reportedas of 2026-11-22
- Complexity Zoo: B (BPP, BQP and related classes) · Complexity Zoo (community wiki) · Secondary source · BQP entry (retrieved 2026-11-22)
- Complexity Zoo: B (BPP, BQP and related classes) · Complexity Zoo (community wiki) · Secondary source · BQP entry (retrieved 2026-11-22)
- Complexity Zoo: B (BPP, BQP and related classes) · Complexity Zoo (community wiki) · Secondary source · BQP entry (retrieved 2026-11-22)
- [15]
Shor's algorithms take a number of steps that grows only polynomially with the input size, such as the number of digits of the integer to be factored. reportedas of 1996-01-25
- Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer (arXiv:quant-ph/9508027) · arXiv (SIAM Journal on Computing 26, 1997) · Secondary source · 1995-08-30 (retrieved 2026-11-21)
- [16]
The Complexity Zoo lists oracle (black-box) results showing that, relative to some oracles, BQP is not contained in the polynomial hierarchy PH, and that relative to a random oracle NP is not contained in BQP; these are evidence, not proofs, about the unrelativised classes. reportedas of 2026-11-22
- Complexity Zoo: B (BPP, BQP and related classes) · Complexity Zoo (community wiki) · Secondary source · BQP entry, oracle results (retrieved 2026-11-22)
- Complexity Zoo: B (BPP, BQP and related classes) · Complexity Zoo (community wiki) · Secondary source · BQP entry, oracle results (retrieved 2026-11-22)
- [17]
The MIP* = RE paper claims that the class MIP*, problems that a classical verifier can decide by questioning several all-powerful quantum provers who share entanglement, equals RE, the class of recursively enumerable languages. reportedas of 2026-11-22
- MIP*=RE · arXiv (version 4, 16 October 2026) · Secondary source · 2020-01-13 · Abstract (retrieved 2026-11-22)
- Landmark Computer Science Proof Cascades Through Physics and Math · Quanta Magazine · Secondary source · 2020-03-04 · Interrogate to Verify (retrieved 2026-11-22)
Revision history (1)
- Page created.
Created Nov 22, 2026. Last reviewed by an editor on Nov 22, 2026. Next scheduled review: Sep 6, 2027.
Cite this page
"Complexity classes explained: P, NP, BQP and beyond." ContentLora, updated Nov 22, 2026. https://contentlora.com/explain/complexity-classes-explained
Spotted an error? Suggest a correction or emailcorrections@contentlora.com.