This preview shows pages 1–2. 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: ECS 222A: Algorithm Design and Analysis Handout ?? UC Davis Charles Martel December 7, 2006 Sample Final Exam A. Describe how to extend the randomized closest point algorithm to points in 3D space (so each point is described by a triple ( x i ,y i ,z i ). What is the expected running time of your 3D algorithm? You may assume in your analysis that hashing an item takes O(1) time. B. Consider the marking algorithm we discussed for caching. i) We divided our access sequence into phases. Does the start/end point of a phase depend on which items we chose to evict? ii) Is the most recently used eviction policy (where we always evict the item which was most recently used) a marking policy? iii) Suppose instead of evicting a random unmarked item we evict a random item from the cache. Give an access sequence which will cause this policy to have almost k times as many expected misses as the optimal. C. Consider the following ideas for approximating the solution to a knapsack problem where we are given n ( v i ,w i ) pairs and a weight limit W . You may assume w i W for all items. i) Let r i = v i /w i . A simple greedy algorithm sorts the items so r 1 r 2 ... r n . Add item 1 to the knapsack, then 2, ..., until the next item doesnt fit. Give an example where this approach gives a solution much smaller than the optimal value. ii) Now consider using the solution in i) or just the single item of largest value (which ever solution has more value). Prove this solution has at last 1/2 the value of the optimal solution. iii) the algorithm as described in i) takes O ( n log n ). Describe how to find this solution in expected O ( n ) time (hint: use median finding). D. Give a dynamic programming algorithm for the traveling salesman problem which runs in O ( n 3 2 n ) time. (20) 1. Two dimensional bin-packing (2DBP)is defined as follows: you are given a list of pairs ( x 1 ,y 1 ) , ( x 2 ,y 2 ) ,..., ( x n ,y n ) where 0 < x i ,y i 1 are the dimensions of the ith item to be packed (thus all items are rectangles). You are also given a parameter k which is the number of 1 by 1 bins which are available to pack the items. The goal is to determine if all items can be packed into at most k bins with the constraint that all items are packed with the side of length y i parallel to the floor of the bin....
View Full Document
This note was uploaded on 01/21/2010 for the course CS 210 taught by Professor Chip during the Fall '09 term at UC Davis.
- Fall '09