NPC vs NPH
NPC vs NPH
| NP-Complete (NPC) | NP-Hard (NPH) | |
|---|---|---|
| Must be in NP? | Yes | No, not necessarily |
| Must be at least as hard as every NP problem? | Yes | Yes |
| Solution can be verified in polynomial time? | Yes | Not necessarily |
| Usually applies to | Decision problems | Decision or optimization problems |
| Example | Hamiltonian Cycle | TSP optimization |
The key idea
NP-Hard:
"This problem is at least as hard as every problem in NP."
NP-Complete:
"This problem is at least as hard as every problem in NP AND its solution can be verified in polynomial time."
Therefore:
Think of it as two conditions
For a problem to be NP-Complete, ask two questions:
1. Is it in NP?
Can we verify a proposed solution in polynomial time?
Yes → continue.
2. Is it NP-Hard?
Is it at least as hard as every problem in NP?
Yes → NP-Complete.
So:
NP-HARD ┌───────────────┐ │ │ │ NP │ │ ┌───────────┐ │ │ │ NPC │ │ │ └───────────┘ │ │ │ └───────────────┘
The NP-Complete problems are the part of NP that is also NP-Hard.
Example: TSP
TSP Optimization
Find the minimum-cost tour visiting every city exactly once.
This is an optimization problem and is NP-Hard.
Why not call it NP-Complete?
Because NP-Complete is defined for decision problems, and this version asks us to find the best tour.
TSP Decision
Is there a tour with total cost ≤ K?
This has a YES/NO answer.
A proposed tour can be verified in polynomial time, and the problem is NP-Hard.
Therefore:
One-line memory trick
🟢 NPC = NP-Hard + Verifiable in polynomial time
or even shorter:
Important: Every NP-Complete problem is NP-Hard, but not every NP-Hard problem is NP-Complete.
Comments
Post a Comment