Complexity Classes

Key computational complexity classes and the problems they contain.

  • JSON4,728 B
  • YAML3,398 B · −28%
  • TOON2,780 B · −41%

The principal computational complexity classes with a description and examples: P, NP, NP-complete, NP-hard, BPP, L and PSPACE, plus co-NP, NL, EXPTIME, BQP, #P and ZPP.

Use it when

  • You need the definition of a complexity class and a canonical problem.
  • You are judging whether a problem is believed to be efficiently solvable.

Watch out for

  • Many relationships between classes are conjectured and unproven, including P versus NP.
  • Class membership concerns worst-case behavior of the best algorithm, not typical instances.

The data

ClassDescriptionExample
PProblems solvable in polynomial time by a deterministic Turing machine.Sorting, shortest path, linear search
NPProblems verifiable in polynomial time by a deterministic TM.SAT, Hamiltonian Path, Subset Sum
NP-CompleteThe hardest problems in NP; all can be reduced to each other.SAT, Knapsack, Traveling Salesman (decision version)
NP-HardAt least as hard as the hardest problems in NP.Halting Problem (undecidable), TSP optimization
BPPProblems solvable in polynomial time with bounded error by a probabilistic TM.Primality testing (AKP primality test)
LProblems solvable using logarithmic space.Graph connectivity, planar graph isomorphism
PSPACEProblems solvable using polynomial space.Quantified Boolean formulas, games
co-NPProblems whose complements are in NP; a 'no' answer has a short certificate.Tautology checking (Is a formula always true?)
NLProblems solvable by a nondeterministic Turing machine using logarithmic space.Directed graph reachability
EXPTIMEProblems solvable in exponential time by a deterministic Turing machine.Generalized chess and checkers on n-by-n boards
BQPProblems solvable in polynomial time by a quantum computer with bounded error.Integer factorization (Shor's algorithm)
#PCounting problems: the number of accepting paths of an NP machine.Counting satisfying assignments of a formula
ZPPProblems solvable by randomized algorithms that always give the right answer in expected polynomial time.Primality testing with zero-error variants

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
dataclassstringP
datadescriptionstringProblems solvable in polynomial time by a deter…
dataexamplestringSorting, shortest path, linear search

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.com/api/dataset/complexity-classes?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/complexity-classes.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Topics

  • algorithms
  • complexity
  • p-vs-np
  • computability

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets