Advanced Topic 37 of 51 Theory & Discrete Math
NP-Completeness
Hardest problems in NP to which all NP reduces.
How it works
A problem is NP-complete if it is in NP and every problem in NP reduces to it in polynomial time, so it is among the hardest problems in NP. If any NP-complete problem had a polynomial-time algorithm, then P would equal NP. Classic NP-complete problems include SAT, 3-SAT, clique, vertex cover, Hamiltonian cycle, traveling salesman in decision form, subset sum, knapsack and graph coloring. Proofs use reductions from a known NP-complete problem.
Step-by-step walkthrough
- A problem is NP-complete if it is in NP.
- And every problem in NP reduces to it in polynomial time.
- So a fast algorithm for one gives a fast algorithm for all.
- Examples: SAT, 3-coloring, Traveling Salesman decision version.
- They are the hardest problems in NP.
Where it is used
Recognizing NP-completeness tells engineers not to search for an exact efficient algorithm for all instances and to use approximation, heuristics, parameterized or special-case algorithms or SAT solvers.
Common pitfall
Proving NP-hardness by reducing in the wrong direction is the standard error. Verify membership in NP as well as hardness. NP-complete is a worst-case notion: many real instances are solved quickly. Pseudo-polynomial algorithms for problems like knapsack do not contradict hardness. Reduce from a problem similar in structure.
Where it fits in the course
NP-Completeness is topic 37 of 51 in Theory & Discrete Math, rated Advanced. It follows Class NP. The next topic is Cook-Levin Theorem.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Theory & Discrete Math quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Theory & Discrete Math quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is NP-Completeness?
Where do people use NP-Completeness?
What is the most common mistake with NP-Completeness?
What should I learn before this topic?
How can I practice it?
Is NP-Completeness hard to learn?
How long does it take to learn NP-Completeness?
Which topics are related to NP-Completeness?
What should I study after NP-Completeness?
Related topics
- Class NP (Theory & Discrete Math)
- Cook-Levin Theorem (Theory & Discrete Math)
- Class P (Theory & Discrete Math)
- P vs NP (Theory & Discrete Math)