{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lect9-medians-selection

# lect9-medians-selection - Lecture Notes CMSC 251 Finally in...

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

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 .

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern