This preview shows page 1. Sign up to view the full content.
Unformatted text preview: (b) Can you do better? Explain your solution. 4. It is straightforward to use 2 n3 comparisons to nd both the minimal and the maximal elements in a given set of n elements (how? you should think about this, but do not need to hand in the answer). Now design a divideandconquer (recursive) algorithm to accomplish the same. Your algorithm should use at most 3 n/ 2 comparisons. (Suppose n is a power of 2 .) 5. Given a blackbox worstcase lineartime algorithm for nding the median, design an algorithm solving the selection problem for an arbitrary order statistic. (In other words, explain how to use the blackbox to nd the kth smallest element.) State and prove the timecomplexity of your algorithm. 1...
View
Full
Document
 Spring '10
 Ray

Click to edit the document details