

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!


ECS 122A: Algorithm Design and Analysis Handout 2 UC Davis — Charles Martel January 14, 2009
(20) Problem 1.
Do parts c, d, and g of Problem 4–1 (p. 85), and part a of Problem 4–4 (pp. 86).
(20) Problem 2. We look at analyzing a variant of the coin changing algorithms discussed in class (and posted on the web page). We consider the setting with pennies, dimes, quarters and half dollars.
(a) The following recurrence can be used to compute C(n) the minimum number of coins to make change.
C(n) = 1 n = 1, n = 10, n = 25, n = 50 = inf inity n < 1 = 1 + M IN (C(n − 1), C(n − 10), C(n − 25), C(n − 50))
When using the non-memoized recursive algorithm to make change (implied by the above recurrence relation), let W (n) be the number of calls to this recursive algorithm used to compute C(n). Write a recurrence relation for W (n). Note: you are not being asked to solve W (n).
(b) Let M (n) denote the number of calls used to compute C(n) using the memoized version of the algorithm. Argue that M (n) = Θ(n). Hint: do not use a recurrence relation.
(20) Problem 3. Consider a variation on the closest point algorithm we discussed (and in section 33.4). If there are 6 or fewer points we solve by brute force. Otherwise we split the points into three sets of (almost) equal size: PL, the leftmost n/3 points, PM , the middle n/3, and PR the rightmost n/3. As before, we then recursively find the closest pair in each of the smaller sets (getting distances dL, dM , dR), and then have to find the closest pair that crosses between two sets. As before you may assume we start by creating two arrays, X and Y with the points sorted by x and y coordinates respectively.
2 ECS 122A Handout 2: Problem Set 2—Due Monday, January 26 3:15PM
(15) Problem 4. Problem 4-3 part a), page 85.
(15) Problem 5. Consider the following proposed improvement to the closest point algorithm we discussed. Suppose we are doing the Combine step using two strips of width d (the closest distance found in PL or PR) and we find a pair of points that are d′^ < d apart. The claim is that we can now adjust both strips to be of size d′. Thus, whenever we find a new, better distance in the Combine step, we adjust the strip width to this new distance.
(15) Problem 6. Problem 5.2-5 on page 99.