← Wiki Index / Computation & Algorithms / Computational Complexity Theory
💻 Computation & Algorithms

Computational Complexity Theory

Computational complexity theory classifies mathematical decision, search, and optimization problems according to the asymptotic time and memory resources required to solve them on abstract computing machines.

Computational complexity theory is the branch of theoretical computer science and mathematics within computation and algorithms that quantifies the intrinsic resource requirements—primarily execution time, memory space, randomness, and circuit depth—needed to solve computational problems as a function of their input size. Whereas computability theory asks whether a problem can be solved in principle by any finite algorithm, computational complexity theory establishes rigorous upper and lower bounds on how efficiently decidable problems can be solved across deterministic, non-deterministic, probabilistic, and quantum models of computation.

In the natural sciences, complexity theory explains why certain physical and biological calculations—such as sorting observations, inverting linear systems, or computing pairwise sequence alignments via dynamic programming—scale effortlessly to millions of variables, whereas seemingly similar problems—such as inferring optimal evolutionary trees under maximum-likelihood phylogenetics, assembling repetitive genomes without a de Bruijn graph transformation, or finding the native energy minimum in ab initio protein folding—encounter combinatorial barriers that no classical computer can brute-force.

Abstract Machines, Asymptotic Notation, and Resource Bounds

Turing Machines and the Cobham–Edmonds Thesis

The standard reference model of computational complexity is the multi-tape deterministic Turing machine (DTM), introduced by Alan Turing in 1936 and formalized for resource-bounded analysis by Juris Hartmanis and Richard Stearns in 1965. An input instance x is encoded as a finite string over a binary or finite alphabet Σ, with input length denoted n = |x| bits (whereas descriptive compressibility of individual strings is studied separately via Kolmogorov complexity and Lempel–Ziv complexity). If a Turing machine halts on every input of length n within at most T(n) head transitions, the machine runs in time complexity T(n); if it visits at most S(n) distinct work-tape cells, it operates in space complexity S(n).

While different physical architectures (such as random-access machines, pointer machines, or multi-tape Turing machines) differ in step counts by polynomial factors of O(n2) or O(log n), the extended Church–Turing (or Cobham–Edmonds) thesis asserts that any reasonable sequential or parallel classical computing device can be simulated by a deterministic Turing machine with at most polynomial overhead. Consequently, the boundary between polynomial time, T(n) = O(nk), and superpolynomial or exponential time, T(n) = O(2n) = O(exp(n ln 2)), remains invariant across classical hardware platforms.

Big-O, Big-Ω, and Big-Θ Asymptotics

To abstract away machine-dependent instruction timings and low-order constants, complexity bounds are expressed using Paul Bachmann, Edmund Landau, and Donald Knuth's asymptotic notation:

  • Asymptotic Upper Bound (O): A function f(n) is in O(g(n)) if there exist positive constants c and n0 such that 0 ≤ f(n) ≤ c · g(n) for all n ≥ n0. An algorithm with worst-case cost O(g(n)) never requires more than a constant multiple of g(n) operations for large inputs.
  • Asymptotic Lower Bound (Ω): A function f(n) is in Ω(g(n)) if there exist positive constants c and n0 such that f(n) ≥ c · g(n) ≥ 0 for all n ≥ n0. Proving that a problem has complexity Ω(g(n)) requires demonstrating that every possible algorithm solving the problem must perform at least c · g(n) operations in the worst case—for instance, the Ω(n log n) information-theoretic comparison lower bound for general sorting.
  • Asymptotically Tight Bound (Θ): A function f(n) belongs to Θ(g(n)) if it satisfies both f(n) = O(g(n)) and f(n) = Ω(g(n)), meaning the upper and lower bounds coincide up to constant factors.

Core Complexity Classes: P, NP, co-NP, PSPACE, and EXPTIME

Deterministic Versus Non-Deterministic Polynomial Time

Complexity theory formulates optimization problems as decision problems—questions with a binary yes/no answer (equivalently, membership of string x in a formal language L ⊆ {0, 1}*). For example, the optimization problem of finding a molecular conformation with minimum Gibbs free energy ΔG is cast as the decision problem of determining whether there exists any conformation with free energy ΔG ≤ k for a target threshold k.

The fundamental hierarchy of deterministic and non-deterministic complexity classes includes:

  • Class L (Logarithmic Space) and NL: Decision problems solvable by a deterministic or non-deterministic Turing machine using O(log n) writable work-tape bits beyond the read-only input tape. By Savitch's theorem (1970), NL ⊆ SPACE(log2 n).
  • Class P (Polynomial Time): All decision problems solvable by a deterministic Turing machine in time O(nk) for some constant k ≥ 1. Problems in P—including shortest paths in weighted graphs (Dijkstra's algorithm), linear programming (Khachiyan's ellipsoid and Karmarkar's interior-point methods), primality testing (Agrawal–Kayal–Saxena), and pairwise biological sequence alignment—are considered computationally tractable at scale.
  • Class NP (Non-Deterministic Polynomial Time): Decision problems for which a "yes" instance possesses a polynomial-length certificate (or witness) y of size |y| = O(nc) that can be verified by a deterministic Turing machine in polynomial time O(nk). Equivalently, NP is the class of languages decidable in polynomial time by a non-deterministic Turing machine that branches across candidate computational paths in parallel. Every problem in P is trivially in NP (P ⊆ NP), because the verifier can solve the problem from scratch while ignoring the certificate.
  • Class co-NP: The complements of languages in NP, where "no" instances possess efficiently verifiable certificates (for example, TAUTOLOGY, the problem of verifying that a Boolean formula evaluates to true under all 2n variable assignments). If P = NP, then NP = co-NP; however, whether NP = co-NP remains an open problem.
  • Class PSPACE (Polynomial Space): Problems solvable using O(nk) memory cells regardless of execution time. Because a machine using p(n) space can visit at most 2O(p(n)) = exp(O(p(n))) distinct configurations before repeating a state in a loop, PSPACE contains both NP and co-NP. Canonical PSPACE-complete problems include evaluating Quantified Boolean Formulas (QBF) and determining winning strategies in generalized board games.
  • Class EXPTIME (Exponential Time): Decision problems solvable by a deterministic Turing machine in time O(2nk) = O(exp(nk ln 2)). By the Hartmanis–Stearns time hierarchy theorem, P ≠ EXPTIME is proven unconditionally via diagonalization.

The containment chain across these classes satisfies:

L ⊆ NL ⊆ P ⊆ NP ⊆ PSPACE ⊆ EXPTIME

Since P is properly contained in EXPTIME (P ⊊ EXPTIME), at least one of the inclusions in the chain P ⊆ NP ⊆ PSPACE ⊆ EXPTIME must be proper, although proving which inclusion is strict—most famously the P versus NP problem—remains the central open question in theoretical computer science and one of the seven Clay Mathematics Institute Millennium Prize Problems.

Complexity ClassDefining Machine & Resource BoundCanonical Complete ProblemRepresentative Scientific / Biological Problem
L / NLDeterministic / Non-deterministic O(log n) spaceDirected graph s–t connectivity (NL-complete)Reachability in finite-state metabolic graphs
PDeterministic O(nk) timeHorn-SAT, circuit value problemPairwise dynamic programming alignment, Eulerian de Bruijn graph path
NPVerifiable certificate in deterministic O(nk) timeBoolean Satisfiability (SAT / 3-SAT)Multiple sequence alignment, 3D HP-lattice protein folding
#P (Sharp-P)Counting total number of accepting certificatesPermanent of a 0–1 matrixPartition function Z = ∑ exp(−E/kBT) of general Ising/Potts spin glasses
PSPACEDeterministic O(nk) memory spaceQuantified Boolean Formulas (QBF)Multi-step stochastic planning and reversible pebble games
EXPTIMEDeterministic O(exp(nk)) timeGeneralized chess/checkers on n × n boardsEquivalence checking of succinct regular expressions

Polynomial-Time Reductions, the Cook–Levin Theorem, and NP-Completeness

Cook–Levin Theorem and Karp's 21 Reductions

To compare the relative difficulty of problems within NP without knowing whether P = NP, Stephen Cook (1971) and Leonid Levin (1973) introduced polynomial-time reductions. A language A is polynomial-time many-one reducible (Karp reducible) to language B, written A ≤p B, if there exists a polynomial-time computable function f such that for every input x, x ∈ A if and only if f(x) ∈ B. If A ≤p B and B ∈ P, then A ∈ P as well. A decision problem B is defined as NP-hard if A ≤p B for every language A ∈ NP, and NP-complete if B is both NP-hard and a member of NP itself.

The Cook–Levin theorem established that the Boolean Satisfiability problem (SAT)—determining whether a Boolean formula in conjunctive normal form admits a truth assignment that satisfies all clauses—is NP-complete. Cook and Levin proved this by constructing a polynomial-size Boolean tableau encoding the step-by-step tape configurations, head positions, and transition rules of any arbitrary non-deterministic polynomial-time Turing machine. In 1972, Richard Karp demonstrated that SAT reduces in polynomial time to 3-SAT (clauses of three literals) and subsequently to 21 classic combinatorial problems—including Clique, Vertex Cover, Subset Sum, Graph Coloring, Hamiltonian Cycle, Steiner Tree, and the decision version of the Traveling Salesperson Problem (TSP)—proving that thousands of seemingly unrelated discrete optimization problems are computationally equivalent up to polynomial factors.

NP-Hardness in Computational Biology and Statistical Physics

NP-completeness pervades quantitative biology, chemistry, and physics:

  1. Phylogenetic Tree Inference: While evaluating the likelihood of a single fixed tree topology takes linear O(n) time via Felsenstein's pruning recurrence, searching across all (2n − 5)!! unrooted bifurcating trees for n taxa is NP-hard under both maximum parsimony (proven by Ronald Graham and Les Foulds in 1982 via reduction from the Steiner tree problem on hypercubes) and maximum-likelihood phylogenetics (proven by Sebastien Roch in 2006).
  2. Multiple Sequence Alignment: Whereas aligning k = 2 sequences of length L takes O(L2) time, Lusheng Wang and Tao Jiang proved in 1994 that multiple sequence alignment under the sum-of-pairs objective function is NP-complete when the number of sequences k is arbitrary, because dynamic programming across a k-dimensional hypercube requires O(2k Lk) = O(exp(k ln(2L))) operations.
  3. 3D Lattice Protein Folding and Spin Glasses: Bonnie Berger and Tom Leighton (1998) and Pierluigi Crescenzi et al. (1998) proved that finding the minimum-energy self-avoiding walk of a hydrophobic–polar (HP) copolymer chain on a two- or three-dimensional lattice—a discrete model of protein folding—is NP-complete. Similarly, Francisco Barahona (1982) proved that finding the ground state of a three-dimensional Ising spin glass is NP-hard, while Leslie Valiant's complexity class #P (Sharp-P) shows that computing the thermodynamic partition function Z = ∑s exp(−H(s) / kBT) is #P-hard even when the corresponding decision problem lies in P.

Coping with Intractability: Parameterized Complexity and Approximation

Fixed-Parameter Tractability (FPT)

Because worst-case NP-hardness is measured solely against total input length n, many scientific problem instances possess structural parameters k—such as treewidth, maximum vertex degree, error rate, or number of reticulate hybridization events—that remain small in empirical data even when n is large. Developed by Rod Downey and Michael Fellows in the 1990s, parameterized complexity classifies a parameterized problem (x, k) as fixed-parameter tractable (FPT) if it can be solved in time:

T(n, k) = f(k) · nO(1)

where f(k) is an arbitrary computable function (such as 2k = exp(k ln 2)) that depends only on the parameter k, and the degree of the polynomial nO(1) is independent of k. For example, finding a Vertex Cover of size k in a graph of n vertices is solvable in O(1.2738k + kn) time (FPT), whereas finding a Clique of size k is W[1]-hard and believed to require nΩ(k) time, where the parameter k remains trapped in the exponent of n.

Approximation Algorithms and the PCP Theorem

When optimal solutions are out of reach, approximation algorithms run in polynomial time and return a feasible solution whose cost C is provably within a multiplicative approximation ratio ρ of the true optimum OPT (C ≤ ρ · OPT for minimization). For metric Traveling Salesperson instances satisfying the triangle inequality, Nicos Christofides's 1976 algorithm combines a minimum spanning tree with a minimum-weight perfect matching to achieve ρ = 3/2. Conversely, the Probabilistically Checkable Proofs (PCP) theorem (Arora, Lund, Motwani, Sudan, and Szegedy, 1998) proves that for problems such as MAX-3SAT and general Clique, approximating the optimum beyond a sharp threshold ratio is itself NP-hard.

Frequently Asked Questions

Why does transforming genome assembly from Hamiltonian paths to Eulerian paths change its complexity class?

In traditional overlap-layout-consensus assembly, each sequencing read is represented as a vertex and overlaps as edges; reconstructing the genome requires finding a Hamiltonian path that visits every vertex once, an NP-complete problem. In a de Bruijn graph, (k − 1)-mers form vertices and k-mers form directed edges; reconstructing the genome requires finding an Eulerian path that traverses every edge once, which Leonhard Euler's degree theorem and Hierholzer's algorithm solve in linear O(|E|) polynomial time.

If protein folding is NP-complete on lattices, how do living cells fold proteins in milliseconds?

Living polypeptides do not perform an exhaustive brute-force search across all ~3N conformational microstates (Levinthal's paradox). Natural evolution has selected amino-acid sequences with funneled free-energy landscapes in which local secondary-structure nucleation and cooperative hydrophobic collapse guide the polypeptide down a steep thermodynamic gradient toward a kinetically accessible native state, bypassing the frustrated glass-like traps used to construct worst-case NP-hardness gadgets.

References

  1. Cook, S. A. (1971). The complexity of theorem-proving procedures. Proceedings of the Third Annual ACM Symposium on Theory of Computing, 151–158. https://doi.org/10.1145/800157.805047
  2. Karp, R. M. (1972). Reducibility among combinatorial problems. In R. E. Miller & J. W. Thatcher (Eds.), Complexity of Computer Computations (pp. 85–103). Plenum Press. https://doi.org/10.1007/978-1-4684-2001-2_9
  3. Arora, S., & Barak, B. (2009). Computational Complexity: A Modern Approach. Cambridge University Press. https://doi.org/10.1017/CBO9780511804090
  4. Berger, B., & Leighton, T. (1998). Protein folding in the hydrophobic-hydrophilic (HP) model is NP-complete. Journal of Computational Biology, 5(1), 27–40. https://doi.org/10.1089/cmb.1998.5.27
  5. Roch, S. (2006). A short proof that phylogenetic tree reconstruction by maximum likelihood is hard. IEEE/ACM Transactions on Computational Biology and Bioinformatics, 3(1), 92–94. https://doi.org/10.1109/TCBB.2006.4
🧬 Support Open Science
Explore interactive science games on LowKey Games or browse scientific apparel & accessories in the CRV Science Shop.
💡 Spot an inaccuracy or have primary literature to expand this article?
Submit a citation or revision note using your shared CRV Science / LowKey Games profile ID.
Suggest Revision