This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CSc 445: Homework 4 Solutions (rev 2) April 1, 2008 1. Monthly Software Purchases Given n distinct growth rates c 1 , . . . , c n , we sort the growth rates into descending order. This can be achieved using, say, Heapsort with a max heap. As we have amply demonstrated previously, such a sort requires time O ( n log n ). Now we must show this yields an optimal cost. Since the structure of this solution is so elementary (it’s simply sorted), we can shortcut the analysis by directly showing that a sorted solution must be optimal. This takes the place of the usual optimal-substructure and greedy-choice proofs. Theorem: A permutation of c 1 , . . . , c n consisting of the growth rates in descending order is an optimal solution (i.e., has a minimum cost). Proof: (By contradiction) Suppose that E * = ( e 1 , . . . , e n ) is a permutation of c 1 , . . . , c n , and has minimum cost, but does not rank the growth rates in descending order. That is, for some index i , with 1 ≤ i < n , e i < e i +1 . Let’s denote the cost of E * with the notation |E * | , i.e., |E * | = $100 + $100 · e 2 + $100 · e 2 3 + ··· + $100 · e n- 1 n = $100 n X k =1 e k- 1 k . If we exchange the order of e i and its successor, we obtain a modified permutation ˆ E , and the difference in cost between these two solutions (using the above notation) is |E * | - | ˆ E| = $100( e 2 + e 2 3 + ··· + e i- 1 i + e i i +1 + ··· + e n- 1 n- e 2- e 2 3- ··· - e i- 1 i +1- e i i- ··· - e n- 1 n ) (1) = $100( e i- 1 i + e i i +1- e i i- e i- 1 i +1 ) (2) = $100 ( e i- 1 i (1- e i ) + e i- 1 i +1 ( e i +1- 1) ) (3) > $100 · e i- 1 i ( (1- e i ) + ( e i +1- 1) ) (4) = $100 · e i- 1 i ( e i +1- e i ) (5) > . Lines (4) and (5) follow because, by hypothesis, e i is smaller than e i +1 , and because each growth rate is greater than unity. Since the difference in costs is positive, this contradicts the assumption that |E * | is the minimum cost, which completes our proof. (Pedantic remark: In the name of clarity, line (1) above implicitly assumed that i was more than 3 and less than n- 1, but of course this restriction is unnecessary.) 1 2. Greedy Set Cover Lemma (corrected) The greedy approach to the given “set cover” problem (which as described seems to be the dominating set problem) chooses at each iteration the unchosen vertex adjacent to the largest number of uncovered vertices, due to its greed. As a warmup, we treat the first iteration separately, because it is easiest to understand. In the first iteration, there are n uncovered vertices, and the greedy algorithm therefore takes a vertex w having the highest degree. Let Δ denote the number of vertices covered by selecting w . Note that it is not possible to cover any more than Δ new vertices at each iteration, and so the size k of an optimal cover must be at least n / Δ vertices. (If each iteration of an optimal series of choices covered Δ new vertices, then k = n / Δ, otherwise k > n / Δ.) As stated, in the first iteration of the greedy algorithm, we cover Δ vertices, and so...
View Full Document