Download presentation
Presentation is loading. Please wait.
1
Order Statistics
2
Selection Problem Input: a set A of n distinct numbers and a number i where i<=n. Output: The element x in A that is larger than exactly i-1 other elements of A. Solutions?
3
Minimum Minimum(A): min = A[1] for i = 2 to n: if min > A[i]: min = A[i] return min
4
Maximum Maximum(A): max = A[1] for i = 2 to n: if max < A[i]: max = A[i] return max
5
Min and Max MinAndMax(A): max = A[1] min = A[1] for i = 2 to n: if max A[i]: min = A[i] return min, max
6
Selection Analysis One group of 5 elements. Median Greater Elements Lesser Elements
7
Selection Analysis All groups of 5 elements. (And at most one smaller group.) Median of Medians Greater Medians Lesser Medians
8
Selection Analysis Definitely Lesser Elements Definitely Greater Elements
9
Selection Analysis elements < x elements > x
10
Simplifications For n > 50, When we SELECT(L,i) or SELECT(H,i-k) we can gaurantee at least ¼ of the elements are strictly less than or greater than x. REMINDER: x is not the median of the entire set! That is why we can’t say ½ the elements are less than or greater to x.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.