- #1
mathmari
Gold Member
MHB
- 5,049
- 7
Hey!
Show that the knapsack problem (Given a sequence of integers $S=i_1, i_2, \dots , i_n$ and an integer $k$, is there a subsequence of $S$ that sums to exactly $k$?) is NP-complete.
Hint:Use the exact cover problem.
The exact cover problem is the follwing:
Given a family of sets $S_1, S_2, \dots , S_n$ does there exist a set cover consisting of a subfamily of pairwise disjoint sets?
So, do I have to reduce the exact cover problem to the knapsack problem??
Could you give me some hints how I could do that?? (Wondering)
Show that the knapsack problem (Given a sequence of integers $S=i_1, i_2, \dots , i_n$ and an integer $k$, is there a subsequence of $S$ that sums to exactly $k$?) is NP-complete.
Hint:Use the exact cover problem.
The exact cover problem is the follwing:
Given a family of sets $S_1, S_2, \dots , S_n$ does there exist a set cover consisting of a subfamily of pairwise disjoint sets?
So, do I have to reduce the exact cover problem to the knapsack problem??
Could you give me some hints how I could do that?? (Wondering)