Skip to content
LiveNext 15:21:49

Definition

What is Computational complexity?

Computational complexity is Computational complexity is the study of how much time and memory a problem needs as it grows, and which problems can be solved efficiently at all.

Computational complexity asks how the cost of solving a problem grows as the problem gets bigger. It sorts problems into classes by how much time or memory the best known method needs, and it asks which problems are fundamentally hard rather than just unsolved.

Measuring growth

Complexity cares about scaling, not stopwatch time. Sorting a list of ten items is trivial. The question is what happens at ten million. Algorithms are described with big-O notation:

  • Linear: double the input, double the work.
  • Quadratic: double the input, four times the work.
  • Exponential: add one item, double the work. These become impractical very fast.

Attention in a transformer is a familiar case. Its cost grows quadratically with the length of the input, which is one reason long context windows are expensive.

The classes that come up most

  • P: problems a computer can solve in polynomial time, which is generally treated as "efficient."
  • NP: problems where a proposed answer can be checked quickly, even if finding one may be slow.
  • NP-hard: problems at least as hard as the hardest in NP.

Whether P equals NP is the best-known open question in the field, covered in P vs NP. Most researchers believe they differ, but no one has proven it. Related conjectures, like the exponential time hypothesis, make sharper claims about how hard specific problems are.

Complexity also studies algebraic versions of these questions, such as comparing the cost of computing certain polynomials, and the exact speed of basic operations. The matrix multiplication exponent is one example: it measures how fast two big grids of numbers can be multiplied, which underlies nearly all of deep learning.

Why it matters to people using AI

Three reasons:

  • Cost. Complexity explains why some AI workloads get costly as inputs grow, and why efficiency tricks matter.
  • Security. Public-key cryptography is built on problems believed to be hard. If a fast algorithm were found for one, the scheme based on it would fail. Hardness is a belief supported by decades of effort, not a proof.
  • Verification. When AI systems claim new proofs or faster algorithms, complexity gives the vocabulary to check what was actually shown. Machine-checked proofs in tools like the Lean theorem prover exist for that reason.

A caution

"Hard in the worst case" does not always mean hard in practice. Many NP-hard problems are solved well enough on real inputs. Complexity describes guarantees, and real workloads often sit comfortably inside them.

Questions people ask

What is the difference between P and NP?

P is the set of problems solvable quickly. NP is the set of problems whose answers can be checked quickly. Whether every NP problem is also in P is unproven.

What does big-O notation mean?

Big-O notation describes how an algorithm's cost grows with the size of its input, ignoring constant factors, such as linear, quadratic or exponential growth.

Computational complexity in the news

#02

Google limits free Gemini to Flash-Lite from October 9

From October 9, the free Gemini app offers only Flash-Lite, and Google AI Plus subscribers lose Pro on a date Google will email them, per Google's help center. Free Gemini is now a sample. Find out this week whether the sample does your work.