Lecture 24
Lecture 24
Lecture No. 24
1
NP Complete Problems
We have proved the following reductions:
CIRCUIT-SAT Hamiltonian Cycle
3-CNF
Vertex Cover
𝒂 = 𝒂
𝒂∈𝑨 𝒂∈𝑺−𝑨
=𝒔−𝒕
Therefore, there exists a partition of X′ into two such
that each partition sums to s−t
Set-Partition
Conversely, suppose there exists a partition of X′ into
two sets such that the sum over each set is s−t.
Then, one of these sets contains the number s−2t.
Removing this number, we get a set of numbers whose
sum is t, and all of these numbers are in X
0-1 Knapsack problem
0-1 Knapsack Decision Problem
Given n items with weights w1, w2,……, wn
and values v1, v2,……, vn and capacity W and value V
Is there a subset S ⊆ {1,2, .., n} such that
σ𝒊 ∈ 𝑺 𝒘𝒊 ≤ 𝑾 and σ𝒊 ∈ 𝑺 𝒗𝒊 ≥ 𝐕?
Theorem:
0-1 Knapsack Problem is NP-complete
0-1 Knapsack problem
Proof:
• 0-1 Knapsack is in NP.
The proof is the set S of items that are chosen and the
verification process is to computeσ𝒊 ∈ 𝑺 𝒘𝒊 and σ𝒊 ∈ 𝑺 𝒗𝒊
This can be done in polynomial time in the size of input
• Claim
Set-Partition ≤𝑷 0-1 Knapsack
0-1 Knapsack problem
Reduction Algorithm Q:
Suppose we are given a set X = {a1, a2,……, an} for the
Set-Partition Problem
Consider the following Knapsack problem:
wi = ai & vi = ai for i = 1,2,…,n &
𝟏 𝒏
𝑾=𝑽= σ 𝒂
𝟐 𝒊=𝟏 𝒊
This process of converting the Set-Partition problem to
0-1 Knapsack problem is polynomial in the input size.
0-1 Knapsack problem
Suppose X is a ‘Yes’ instance for the Set-Partition
problem.
Then there exists a subset S of X such that
𝟏
σ𝒊 ∈ 𝑺 𝒂𝒊 = σ𝒊 ∈𝑿−𝑺 𝒂𝒊 = σ𝒏𝒊=𝟏 𝒂𝒊
𝟐
Let our Knapsack contain the items in S
𝟏 𝒏
Then σ𝒊 ∈ 𝑺 𝒘𝒊 = σ𝒊 ∈ 𝑺 𝒂𝒊 = σ𝒊=𝟏 𝒂𝒊 = W
𝟐
𝟏 𝒏
And σ𝒊 ∈ 𝑺 𝒗𝒊 = σ𝒊 ∈ 𝑺 𝒂𝒊 = σ𝒊=𝟏 𝒂𝒊 = V
𝟐
0-1 Knapsack problem
Conversely, Suppose Q(X) is a ‘Yes’ instance for the 0-1
Knapsack problem
Let S be the set chosen for the 0-1 Knapsack problem
𝟏
We have σ𝒊 ∈ 𝑺 𝒘𝒊 = σ𝒊 ∈ 𝑺 𝒂𝒊 ≤ W = σ𝒏𝒊=𝟏 𝒂𝒊 and
𝟐
𝟏 𝒏
σ𝒊 ∈ 𝑺 𝒗𝒊 = σ𝒊 ∈ 𝑺 𝒂𝒊 ≥ V = σ 𝒂
𝟐 𝒊=𝟏 𝒊
𝟏 𝒏
Thereforeσ𝒊 ∈ 𝑺 𝒂𝒊 = σ𝒊 ∈ 𝑿 − 𝑺 𝒂𝒊 = σ𝒊=𝟏 𝒂𝒊
𝟐
Thus S is the required subset of X.