NP Completeness
NP Completeness
Example :
Assume we have a decision algorithm X for
0/1 Knapsack problem with capacity M,
i.e. Algorithm X returns “Yes” or “No” to the
question
“Is there a solution with profit ≥ P subject to
knapsack capacity ≤ M?”
We can repeatedly run algorithm X for
various profits(P values) to find an optimal
solution.
Example : Use binary search to get the
optimal profit,
maximum of lg ∑pi runs.
(where M is the capacity of the knapsack optimization problem)
not
hamilton
ian
Is P = NP?
P
N
• Any problem in P is also in NP: P
P ⊆ NP
• The big (and open question) is whether NP
⊆ P or P = NP
– i.e., if it is always easy to check a solution,
should it also be easy to find a solution?
NP-Completeness (informally)
P NP-complete
• NP-complete problems are NP
• If L1 ∝ L2 then L2 is in P implies L1 is in P
• If L1 ∝ L2 and L2 ∝ L3 then L1 ∝ L3
• P: (Decision) problems solvable by deterministic
algorithms in polynomial time
• NP: (Decision) problems solved by non-deterministic
algorithms in polynomial time
• A group of (decision) problems,
including all of the ones we have NP-Complete
discussed (Satisfiability, 0/1
Knapsack, Longest Path, Partition)
have an additional important NP
property:
If any of them can be solved in P
polynomial time, then they all
can! problems are called NP-complete problems.
• These