{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW4 Solutions

# HW4 Solutions - CSc 445 Homework 4 Solutions(rev 2 April 1...

This preview shows pages 1–3. Sign up to view the full content.

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 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) > 0 . 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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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 0 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 0 / Δ vertices. (If each iteration of an optimal series of choices covered Δ new vertices, then k = n 0 / Δ, otherwise k > n 0 / Δ.) As stated, in the first iteration of the greedy algorithm, we cover Δ vertices, and so n 1 = n 0 - Δ n 0 - n 0 k .
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern