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 , . 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 and are time-constructible functions, and is asymptotically smaller than , then is strictly contained within .
- Space Hierarchy Theorem: Similar to the time hierarchy theorem, there exists a space hierarchy such that problems solvable with 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 Class | Description | Example Problem |
| P | Solvable in polynomial time by a deterministic machine | Integer Addition |
| NP | Solutions verifiable in polynomial time | Traveling Salesman Problem |
| NP-Complete | Hardest problems in NP, everything reducible to them | Boolean Satisfiability Problem (SAT) |
| EXP | Solvable in exponential time | Chess |
| PSPACE | Solvable with polynomial space | Quantified 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.

