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 divideandconquer 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 difﬁcult to solve optimally.
Suppose that you are given a set of
n
numbers. Deﬁne 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 ﬁnal 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 deﬁned 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 deﬁne
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 signiﬁcantly bias the average, whereas it cannot have a signiﬁcant inﬂuence
on the median. They are also useful, since in divideandconquer 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.
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.
 Fall '11
 Staff

Click to edit the document details