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 n-3 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 divide-and-conquer (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 black-box worst-case linear-time 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 black-box to nd the k-th smallest element.) State and prove the time-complexity of your algorithm. 1...
View Full Document
- Spring '10