This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Spring 2010 CS530 – Analysis of Algorithms Homework 10 H OMEWORK 10, DUE A PRIL 28 You must prove your answer to every question. Problems with a ( * ) in place of a score may be a little too advanced, or too challenging to most students, so I do not assign a score to them. But I will still note if you solve them. Problem 1. The knapsack problem is defined as follows. Given are integers b a 1 ,..., a n 0, and integer weights w 1 ,..., w n 0. Maximize ∑ i w i x i subject to ∑ i a i x i ¶ b , where x i ∈ { 0,1 } . Consider the following greedy algorithm for the knapsack problem. Sort the objects by decreasing ratio of w i / a i of profit to size, and then pick objects in this order as long as the sum of the a i does not exceed b . (a) Show that this algorithm can be made to perform arbitrarily badly (with an arbitrarily large approximation ratio). Solution. Let m be a large integer. Let n = 2, a 1 = 1, a 2 = b = 2 m , w 1 = 1, w 2 = m . The ratios are 1,1 / 2. Then the algorithm picks a 1 with ratio 1 and cannot pick a 2 anymore. The value is w 1 = 1. But we could1....
View
Full
Document
This document was uploaded on 10/05/2010.
 Spring '09
 Algorithms

Click to edit the document details