{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Chapter 9 - SHEN'S CLASS NOTES Chapter 9 Medians and Order...

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

SHEN’S CLASS NOTES Chapter 9 Medians and Order Statistics Suppose a 1 < a 2 < a 3 < … < a n are n numbers. a 1 is called the first order statistics (or, the minimum number). a 2 is called the second order statistics (the 2nd smallest number). …… a i is called the ith order statistics (the ith smallest number). a n is called the nth order statistics (also the maximum number). If n is an odd number then the index i = ( n +1)/2 is the midpoint and a i = a ( n +1)/2 is called the median. If n is an even number then a i = a ( n +1)/2 is called the lower median, and 1

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

View Full Document
SHEN’S CLASS NOTES a i = a ( n +1)/2 is called the upper median. For simplicity, we refer to the lower median a ( n +1)/2 as the median. The selection problem is to find the ith order statistic for a given set of n unsorted numbers and an integer i , 1 i n . Obviously, we can use sorting to solve the selection problem which needs Θ ( n lg n ) time. However, we have a linear time algorithm for the selection problem. Minimum and maximum A simple linear search below can find the maximum. Maximum (A[1.. n ]) 1. max ← A[1] 2. for i ← 2 to length ( A ) 3. do if max < A[ i ] 4. then max ← A[ i ] 2
SHEN’S CLASS NOTES 5. r eturn max End. This algorithm needs ( n- 1) comparisons to find the maximum number. We can show that any algorithm needs at least ( n -1) comparisons to find the maximum. If we call the larger number in a comparison the winner and the smaller one looser, then a

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 ]}

### Page1 / 11

Chapter 9 - SHEN'S CLASS NOTES Chapter 9 Medians and Order...

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

View Full Document
Ask a homework question - tutors are online