CS432, Fall 2005 Solutions for HW6 Q1: --- This won't be on the exam, so no need to give details (I don't think). A Google search will take you the Clay Mathematics Institute pages or the Minesweeper work's home-page. We hope this quick look will convince you that many of these odd-seeming NP-c problems crop up in "everyday" situations (e.g. maximizing the number of filled rows). While often the probem sizes are small enough that things work out (we *can* play Tetris, after all), perhaps it's not a surprise that part of what makes many puzzles and certain games (their modern computer-based counterparts) hard is something to do with the fact that they're based on hard problems (i.e. NP-c problems). Q2: --- A) What is the difference between a software patent and a copyright? Answer: See content item #1 here: http://en.wikipedia.org/wiki/Software_patent B) If Strassen were to have submitted his matrix multiplication algorithm to the US Patent Office in the last few decades, do you think his patent would have been accepted? Say why or why not. Answer: Almost certainly not, since this is a good example of a "mathematical expression" or algorithm. Two questions on "captcha": C-1) As a computer scientist, do you think what has been patented here is an algorithm that is described clearly and precisely? Is it something larger than an algorithm? Answer: Clearly this is larger than one algorithm; it's probably a reasonable example of the kind of "process" described in the readings (like one-click shopping). In my opinion, it's described reasonably clearly but not described as precisely as an algorithm; it's more like a description of a family of algorithms. C-2) Also, in your or your group's opinion, do you think governments should patent things like this? Give your reasons. (They can be technical ones related to this patent, or broader reasons based on philosophy or societal issues.) Answer: Better answers will have some basis obtained from what they read (and not just their opinion/feelings). Q3: Showing 0/1 Knapsack is NP-hard ------------------------------------ As noted in the book, slides and lecture, we need to show a polynomial reduction from a known NP-c (or NP-hard) problem to the 0/1 knapsack. The problem tells you to use SubsetSum problem. So show any input x of SubsetSum can be transformed into a valid input T(x) for 0/1-Knapsack, where x will be accepted by SubsetSum if and only if T(x) is accepted by 0/1- Knapsack. Each of the n items for subset sum have a value, i.e. x_i. There's also a target value, k, for subset sum. The hints try to make you see that if you just need to do this: 1) simply map each item in the subset sum problem to one item for 0/1 knapsack. 2) for each item, give both the knapsack value and weight for that item the x_i value from the subset sum input. 3) give both W and k for the knapsack the value k from the subset sum input. This is trivially polynomial. Steps 1/2 above are Theta(n) and Step 3 is constant. Why is this a valid transformation? Try it on the two examples in the problem and you'll see. The constraint on the weights will make sure that the sum of the items is <= the original k value. The constraint on the values will make sure the sum of the items is >= the orginal k. A value can only be *both* >= *and* <= some target if is is exactly equal, which is what we want. So in one sense, the subset sum problem is just a simplified version of the 0/1 knapsack problem. And, with this transformation and the dynamic programming solution to 0/1 knapsack, you can solve the subset sum problem directly! NOTE: In HW5, you showed that the 0/1 knapsack problem is in NP. Here in HW6 you just showed that it's NP-hard, i.e. that any problem in NP can be reduced to 0/1 knapsack. So both of these things together prove that 0/1 knapsack is NP-c.