
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Fall 2002 Khuller & Postow
CMSC 351 Solutions to Homework 1
Solution 1.
∑^ n i=
(^3) ∑i+
j=i
∑^ n i=
(2i + 2) =
∑^ n i=
2 i +
∑^ n i=
n(n + 1) 2
Solution 2. Sort the numbers. Now assume that x 1 is the smallest, x 2 the next smallest and so on. Note that we should pair x 2 n (largest number) with x 1 the smallest number. To see this formally, suppose that the OPT solution pairs x 2 n with some number xp and x 1 with xj. By doing an exchange, and producing the pairing (x 2 n, x 1 ) and (xp, xj ) we get a solution with lower cost, since x 2 n + x 1 ≤ x 2 n + xp and xp + xj ≤ x 2 n + xp. We now continue to do the pairing in this way. The maximum pair that we produce is our cost.
Solution 3. We only give the solution for part (a). If you sort all the numbers using merge sort, then all the duplicate numbers appear consecutively. It is easy to compute the mode in a single scan of the numbers now. This algorithm takes time O(n log n).
Solution 4. It is easy to verify the claim for n = 1. The LHS is 1, and the RHS is
i=
i^2 = (m + 1)(m + 2)(2m + 3) 6
Consider the LHS. (^) m ∑
i=
i^2 + (m + 1)^2.
This is (m)(m+1)(2 6 m+1)+ (m + 1)^2. Simplifying, gives us (m + 1) 2 m (^2) +7m+ 6.^ This is the same as the RHS. (Since (m + 2)(2m + 3) = 2m^2 + 7m + 6.)