lect9-medians-selection

lect9-medians-selection - Lecture Notes CMSC 251 Finally,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture Notes CMSC 251 Finally, in the recurrence T ( n )=4 T ( n/ 3) + n (which corresponds to Case 1), most of the work is done at the leaf level of the recursion tree. This can be seen if you perform iteration on this recurrence, the resulting summation is n log 3 n X i =0 ± 4 3 ² i . (You might try this to see if you get the same result.) Since 4 / 3 > 1 , as we go deeper into the levels of the tree, that is deeper into the summation, the terms are growing successively larger. The largest contribution will be from the leaf level. Lecture 9: Medians and Selection (Tuesday, Feb 24, 1998) Read: Todays material is covered in Sections 10.2 and 10.3. You are not responsible for the randomized analysis of Section 10.2. Our presentation of the partitioning algorithm and analysis are somewhat different from the ones in the book. Selection: In the last couple of lectures we have discussed recurrences and the divide-and-conquer method of solving problems. Today we will give a rather surprising (and very tricky) algorithm which shows the power of these techniques. The problem that we will consider is very easy to state, but surprisingly difficult to solve optimally. Suppose that you are given a set of n numbers. Define the rank of an element to be one plus the number of elements that are smaller than this element. Since duplicate elements make our life more complex (by creating multiple elements of the same rank), we will make the simplifying assumption that all the elements are distinct for now. It will be easy to get around this assumption later. Thus, the rank of an element is its final position if the set is sorted. The minimum is of rank 1 and the maximum is of rank n . Of particular interest in statistics is the median .If n is odd then the median is defined to be the element of rank ( n +1) / 2 . When n is even there are two natural choices, namely the elements of ranks n/ 2 and ( n/ 2) + 1 . In statistics it is common to return the average of these two elements. We will define the median to be either of these elements. Medians are useful as measures of the central tendency of a set, especially when the distribution of val- ues is highly skewed. For example, the median income in a community is likely to be more meaningful measure of the central tendency than the average is, since if Bill Gates lives in your community then his gigantic income may significantly bias the average, whereas it cannot have a significant influence on the median. They are also useful, since in divide-and-conquer applications, it is often desirable to partition a set about its median value, into two sets of roughly equal size. Today we will focus on the following generalization, called the selection problem . Selection: Given a set A of n distinct numbers and an integer k , 1 k n , output the element of A of rank k .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2012 for the course CMSC 351 taught by Professor Staff during the Fall '11 term at University of Louisville.

Page1 / 6

lect9-medians-selection - Lecture Notes CMSC 251 Finally,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online