[Return to Solutions Page]

COMP-360 Assignment #5 Solutions

Questions 1 - 4 are out of 10 and question 5 is out of 40, for a total of 80 marks overall. For questions about the assignment or about the marking scheme, please contact Theresa at theresa (dot) deering (at) mail.mcgill.ca (questions 1 and 2) or Gheorghe (questions 3 and 4) at ghitzah (at) gmail (dot) com or both (question 5). View the questions here.

  1. For solution, see here.

  2. For solution, see here.

  3. First, we need to show that the problem SHIP is in NP. The certificate is the set of items to send. The polynomial time certifier is to check that the total value of the items is greater than or equal to C, the total weight of the items is less than or equal to W, and the total volume of the items is less than or equal to V.

    Second, we choose a known-NP complete problem to reduce from. We will reduce SUBSET SUM to SHIP.

    Third, we morph the general SUBSET SUM problem into an instance of the SHIP problem. Note the definition of SUBSET SUM: Given a set of natural numbers a1, ..., an, is there a subset such that the elements sum to exactly the integer A?
    Set ci = ai for i = 1, ..., n
    Set wi = ai for i = 1, ..., n
    Set vi = ai for i = 1, ..., n
    Set C = A
    Set W = A
    Set V = A

    Last, we prove that it works:
    If we have a subset that sums exactly to A then we have a set of items to ship that has a cost summing exactly to C, a weight summing exactly to W, and a volume summing exactly to V. This is a set that it is worth it to ship.
    If we have a set that is worth it to ship, then we have its cost summing to at least C = A and its weight summing to at most W = A. Since all the cis equal all the wis, we know that total is both at least A and at most A. Thus, the totals C, W, and V all equal A. This gives us a set of objects that sum exactly to A, our SUBSET SUM.

[Return to Solutions Page]