AI Glossary / Graphs and symbolic AI / Intermediate
NP-complete
Definition
NP-complete describes a decision problem that is both in NP and NP-hard under the specified polynomial-time reductions. Being in NP means that a yes answer has a polynomial-size certificate checkable in polynomial time. Being NP-hard means that every problem in NP can be efficiently transformed into it. These problems occupy a central place in understanding computational difficulty.
What it means
A decision problem asks a yes-or-no question, such as whether a graph has a clique of at least a given size. Finding the largest clique is a related optimization problem, but the formal NP-complete label applies to the decision formulation.
The distinction between finding and checking matters. If somebody supplies a proposed clique, checking all its required edges is straightforward. Finding such a set, or establishing that none exists, may require much more work. NP does not stand for “not polynomial”; it refers to nondeterministic polynomial time, with efficient certificate verification providing an equivalent standard characterization.
How it works
To classify a decision problem as NP-complete, establish two properties. First, describe a polynomial-time verifier for valid yes certificates. Second, prove NP-hardness, commonly by transforming a known NP-complete problem into the new problem in polynomial time while preserving yes and no answers.
The reduction direction is important: a solver for the new problem must let us solve the known hard problem. Merely translating the new problem into an already hard one does not establish hardness of the new problem.
If any NP-complete problem has a deterministic polynomial-time algorithm for all inputs, then P=NP. The standard classification does not itself prove that no such algorithm exists. It describes a relationship among problem classes and reductions, rather than a runtime prediction for every individual input.
Three practical examples
- Planning software: recognize that a general feasibility problem may require exact search, restrictions, or practical heuristics rather than a simple universally efficient algorithm.
- Solver evaluation: separate easy-to-check proposed solutions from the effort needed to find them or prove infeasibility.
- Technical purchasing: assess claims that a system solves a general hard problem quickly by asking about instance restrictions and guarantees.
Think of it this way
Think of a large collection of puzzles that can all be translated efficiently into one representative puzzle type. A universally fast solution to that representative would unlock the whole collection.
The analogy does not mean that every puzzle instance is difficult. Some are tiny or have obvious solutions, and translation can change practical size. NP-completeness concerns worst-case families as input size grows.
Worked example
Consider the CLIQUE decision problem: given an undirected graph and integer k, does a set of at least k vertices exist with every pair connected? Take vertices A,B,C,D,E and edges AB,AC,BC,CD,DE. Ask whether a clique of size at least three exists.
The certificate {A,B,C} can be checked by inspecting AB, AC, and BC. All three edges exist, so the answer is yes. The proposed certificate {B,C,D} fails because BD is missing, even though BC and CD exist.
For a proposed set of k vertices, there are k(k−1)/2 pairs to inspect. The verifier must also check that the listed vertices are distinct and belong to the graph. This gives polynomial verification with a suitable graph representation.
Now ask for a clique of size four in the same graph. None exists: D connects only to C and E, while E connects only to D, and the remaining A,B,C provide only three vertices. This small no answer is easy to establish directly. The example illustrates certificates and particular instances; it is not a proof of CLIQUE's NP-hardness and does not imply that arbitrary no instances are equally easy to settle.
Illustrative case study
Fictional case: a scheduling startup describes its engine as solving an NP-complete problem instantly. Review reveals that its customer instances have a fixed small number of resources and that the system sometimes returns a feasible schedule without proving optimality.
The team revises its description to state the supported instance sizes, constraints, and guarantees. It evaluates difficult representative cases separately from demonstrations with obvious answers. The fictional case illustrates precise product claims, not a measured limitation of any actual solver.
Common misconceptions and mistakes
NP-complete does not mean unsolvable. Finite instances can often be solved exactly, and many practical instances are manageable with modern algorithms. The concern is general worst-case scaling.
It also does not mean every algorithm must enumerate every possibility, nor does it prove an exponential lower bound. Such claims go beyond the classification. Heuristics, preprocessing, parameterized algorithms, and special-case structure can matter greatly.
Do not confuse NP-hard and NP-complete. NP-complete problems belong to NP as well as being NP-hard. An optimization problem can be NP-hard without being a decision problem to which the standard NP-complete label directly applies.
Business use
The label helps teams choose realistic solution strategies and communicate guarantees. Ask whether the task needs an exact optimum, any feasible solution, an approximation with a bound, or a useful heuristic result within a deadline.
Measure performance on the actual problem distribution, including difficult and infeasible cases. Identify structural restrictions that simplify the task. A general complexity classification is valuable context, but it cannot replace implementation benchmarking or careful definition of what the system promises to return.
People also ask
Does NP-complete mean no fast solution is possible?
It means a general polynomial-time solution would imply P=NP. The classification alone does not prove impossibility.
Can an NP-complete problem have easy instances?
Yes. Worst-case classification does not make every instance difficult.
Is checking a yes certificate the same as finding one?
No. A verifier checks a supplied candidate; a solver must find an answer without being handed that certificate.
Check your understanding
A proposed four-vertex clique has five of its six required edges. Is it a valid certificate?
Answer: No. Every pair must be connected, so the missing edge invalidates the proposed clique.
Related terms
- Computational complexity
- Satisfiability
- P
- NP
- NP-hard
- polynomial-time reduction
- certificate
- decision problem
- clique
Learn next
distinguish decision, search, and optimization versions of one problem. Then trace a simple polynomial reduction and explain why its direction establishes the intended hardness claim.
More in Graphs and symbolic AI
- Nonparametric density estimation - Nonparametric density estimation estimates the shape of a probability distribution from observed data without restricting it to a fixed finite-dimensional...
- Nonparametric model - A nonparametric model is a statistical or machine-learning model whose flexibility is not restricted to a fixed finite-dimensional parameterization chosen...
- Nonserial dynamic programming - Nonserial dynamic programming is a method for solving structured problems by eliminating variables and storing summaries of their interactions with the...
- NP-completeness - NP-completeness is the complexity-theoretic property of a decision problem that is both efficiently verifiable and at least as hard as every problem in NP...
- Null move - A null move is a hypothetical move in which a player passes the turn without making an ordinary action on the board.
- Null-move heuristic - The null-move heuristic is a selective game-search technique that tests a position by hypothetically passing the current player's turn and searching the...
Sources
Cornell's course material defines P, NP, and NP-completeness and explains their relationships: https://www.cs.cornell.edu/courses/cs2800/2015fa/lectures/lec36-np.html
Cornell's reductions handout explains proof direction and decision-problem transformations: https://www.cs.cornell.edu/courses/cs4820/2013sp/Handouts/reductions.pdf
The five-vertex example and fictional scheduling case are original illustrations.
Previous: Novelty detection Next: NP-completeness