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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 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 number is the maximum if and only if this number is the winner
Background image of page 3

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

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

This note was uploaded on 04/12/2008 for the course CS 592 taught by Professor Shen during the Fall '05 term at University of Missouri-Kansas City .

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 Right Arrow Icon
Ask a homework question - tutors are online