computational complexity
complexity theory
computer science
algorithms
theoretical computer science

Explaining computational complexity theory

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Computational Complexity Theory is a branch of theoretical computer science that investigates the resources required to solve computational problems, primarily time and space, and classifies problems based on how difficult they are to solve. It stands as a crucial domain because it allows us to understand the limits of what can be computed efficiently.

Key Concepts in Computational Complexity Theory

1. Complexity Classes

Complexity classes are categories of problems classified by the resources needed to solve them.

  • P (Polynomial Time): This class includes all decision problems (problems with a yes/no answer) that can be solved by a deterministic Turing machine in polynomial time.
  • NP (Nondeterministic Polynomial Time): A decision problem is in NP if a "yes" answer can be verified by a deterministic Turing machine in polynomial time. Whether P equals NP is one of the most significant open questions in computer science.
  • Co-NP: Contains decision problems for which the "no" instances can be verified in polynomial time.
  • EXP (Exponential Time): This class includes problems that can be solved by a deterministic Turing machine in exponential time.
  • PSPACE: This class contains problems solvable by a Turing machine using a polynomial amount of space.

2. Reductions and Completeness

A problem is said to be complete for a complexity class if it is the most difficult problem in that class.

  • NP-Complete: A problem is NP-complete if it is in NP and every problem in NP can be reduced to it using a polynomial-time reduction.
  • Example: The Traveling Salesman Problem, where given a list of cities and the distances between them, you must find the shortest possible route that visits each city exactly once and returns to the origin city.

3. Savitch's Theorem and the Space Complexity

Savitch's theorem states that for any function f(n)log(n)f(n) \geq \log(n), NSPACE(f(n))DSPACE(f(n)2)NSPACE(f(n)) \subseteq DSPACE(f(n)^2). It implies that nondeterminism does not provide exponential savings in space.

4. Time and Space Hierarchy Theorems

These theorems formalize the notion that more time or space allows solving more problems.

  • Time Hierarchy Theorem: If f(n)f(n) and g(n)g(n) are time-constructible functions, and f(n)f(n) is asymptotically smaller than g(n)g(n), then DTIME(f(n))DTIME(f(n)) is strictly contained within DTIME(g(n))DTIME(g(n)).
  • Space Hierarchy Theorem: Similar to the time hierarchy theorem, there exists a space hierarchy such that problems solvable with f(n)f(n) space are strictly less than those solvable with more space.

5. Practical Implications

Theoretical results of computational complexity have practical implications:

  • Algorithm Design: Helps understand which problems can be feasibly solved and which are likely infeasible.
  • Cryptography: Many encryption schemes rely on the assumption that certain problems (e.g., factoring integers) are infeasible to solve in polynomial time.

Summary Table

Complexity ClassDescriptionExample Problem
PSolvable in polynomial time by a deterministic machineInteger Addition
NPSolutions verifiable in polynomial timeTraveling Salesman Problem
NP-CompleteHardest problems in NP, everything reducible to themBoolean Satisfiability Problem (SAT)
EXPSolvable in exponential timeChess
PSPACESolvable with polynomial spaceQuantified Boolean Formulas (QBF)

Additional Topics

6. Probabilistic Complexity Classes

  • BPP (Bounded-error Probabilistic Polynomial Time): Problems that can be solved with an error probability of less than 1/3 in polynomial time by a randomized Turing machine.

7. Approximation and Heuristics

In cases where exact solutions are computationally infeasible, approximation algorithms provide near-optimal solutions in polynomial time. Heuristics are practical methods for problem solving, usually faster, but without guarantee of optimality.


Computational complexity theory continues to be a dynamic field of research, providing fundamental insights into the capabilities and limits of computational processes. Understanding it is essential for algorithm designers and computer scientists aiming to tackle complex problems efficiently.


Course illustration
Course illustration

All Rights Reserved.