0 views

Uploaded by William Yen

Medians and Order Statistics

- alg_notes
- 8-4 group 7 m m lab1
- Shell Sort
- Engineering a Sort Function
- Cracking System Design Interview Like A Pro – A 10 Day
- Ch 11 管理個案：空軍訓練計畫.docx
- Data Structure Notes
- Computer Programming
- Program
- A Novel Sorting Technique to Sort Elemen
- IT321- Data - Part 1
- Lecture 9
- PPC Index
- DsSort
- DAAQBI-V
- statistik_data_analysis.pdf
- edexcel s1 revision Notes
- 4.1-4.3 Quiz
- Affinity Diagram
- Microsoft PowerPoint - 5 Assignement and lab tutorial

You are on page 1of 19

CLRS Chapter 9

1

What Are Order Statistics?

The k-th order statistic is the k-th smallest element of an array.

3 4 13 14 23 27 41 54 65 75

n

The lower median is the -th order statistic

2

If n is odd, lower and upper median are the same

3 4 13 14 23 27 41 54 65 75

What are Order Statistics?

Selecting ith-ranked item from a collection.

First: i=1

Last: i=n

n n

Median(s): i = ,

2 2

3

Order Statistics Overview

find ith order stat = A[i]

(n).

I can find max and min in (n) time (obvious)

Can we find any order statistic in linear time? (not

obvious!)

4

Order Statistics Overview

expected-case (n)?

?

?

Pivot, partition, but recur only on one set of data. No join.

5

Using the Pivot Idea

Randomized-Select(A[p..r],i) looking for ith o.s.

if p = r

return A[p]

q <- Randomized-Partition(A,p,r)

k <- q-p+1 the size of the left partition

if i=k then the pivot value is the answer

return A[q]

else if i < k then the answer is in the front

return Randomized-Select(A,p,q-1,i)

else then the answer is in the back half

return Randomized-Select(A,q+1,r,i-k)

6

Randomized Selection

Analyzing RandomizedSelect()

Worst case: partition always 0:n-1

T(n) = T(n-1) + O(n)

= O(n2)

No better than sorting!

Best case: suppose a 9:1 partition

T(n) = T(9n/10) + O(n)

= O(n) (Master Theorem, case 3)

Better than sorting!

Average case: O(n) remember from quicksort

7

Worst-Case Linear-Time Selection

Randomized algorithm works well in practice

What follows is a worst-case linear time algorithm,

really of theoretical interest only

Basic idea:

Guarantee a good partitioning element

Guarantee worst-case linear time selection

Warning: Non-obvious & unintuitive algorithm

ahead!

Blum, Floyd, Pratt, Rivest, Tarjan (1973)

8

Worst-Case Linear-Time Selection

The algorithm in words:

1. Divide n elements into groups of 5

2. Find median of each group (How? How long?)

3. Use Select() recursively to find median x of the n/5 medians

4. Partition the n elements around x. Let k = rank(x)

5. if (i == k) then return x

if (i < k) then use Select() recursively to find ith smallest

element in first partition

else (i > k) use Select() recursively to find (i-k)th smallest

element in last partition

9

Order Statistics: Algorithm

Select(A,n,i): T(n)

Divide input into n/5 groups of size 5. O(n)

All this

/* Partition on median-of-medians */ to find a

medians = array of each groups median. O(n) good split.

pivot = Select(medians, n/5 , n/10 ) T( n/5 )

Left Array L and Right Array G = partition(A, pivot) O(n)

k = |L| + 1 O(1)

If i=k, return pivot O(1)

Only one

If i<k, return Select(L, k-1, i) T(k)

done.

If i>k, return Select(G, n-k, i-k) T(n-k)

10

Order Statistics: Analysis

#less #greater

n

T n T T max k - 1, n - k O(n)

5

How to simplify?

11

Order Statistics: Analysis

Lesser

Elements

Median

Greater

Elements

12

Order Statistics: Analysis

Lesser Median of Greater

Medians Medians Medians

(And at most one smaller group.)

13

Order Statistics: Analysis

Definitely Lesser

Elements

Definitely Greater

Elements

14

Order Statistics: Analysis 1

How many?

15

Order Statistics: Analysis 1

n 5 2 full groups of 5 n 5 2 partial groups of 2

Count elements n n 7n

At most 5 2 2 2 6

outside smaller box.

5 5 10 16

Order Statistics: Analysis

n 7n

T n T T 6 On

5 10

? ?

17

Order Statistics: Analysis

Substitution: Prove Tn c n .

n 7n

T n c c 6 d n

5 10

n 7n

c 1 c 6 d n Overestimate ceiling

5 10

9

c n 7c d n Algebra

10

c n c n 10 7c d n Algebra

c n

when choose c,d such that 0 c n 10 7c d n

18

Order Statistics

Why groups of 5?

? ?

Sum of two recurrence sizes must be < 1.

Grouping by 5 is smallest size that works.

19

- alg_notesUploaded byAnonymous GNWnQac
- 8-4 group 7 m m lab1Uploaded byapi-334898273
- Shell SortUploaded byDjJethro Bagcat Fernandez
- Engineering a Sort FunctionUploaded byMichael Shannon
- Cracking System Design Interview Like A Pro – A 10 DayUploaded bybrian
- Ch 11 管理個案：空軍訓練計畫.docxUploaded by周書豪
- Data Structure NotesUploaded byKumar Raja
- Computer ProgrammingUploaded byKishor Peddi
- ProgramUploaded byNeerajBhargava
- A Novel Sorting Technique to Sort ElemenUploaded byHitesh Mohapatra
- IT321- Data - Part 1Uploaded byrayden22
- Lecture 9Uploaded byGodwin Reuben Urioh
- PPC IndexUploaded byDiana Mihai
- DsSortUploaded bymanuelq9
- DAAQBI-VUploaded bydgk84_id
- statistik_data_analysis.pdfUploaded bySimone Meschino
- edexcel s1 revision NotesUploaded byminamakin
- 4.1-4.3 QuizUploaded byblessingtraci
- Affinity DiagramUploaded byAmin Chhipa
- Microsoft PowerPoint - 5 Assignement and lab tutorialUploaded byAhmed Alamin
- se and dsUploaded bySivasankaran Subramanian
- Lower QuartileUploaded byRam Singh
- Making a Stem and Leaf Plot Using MinitabUploaded byryanbalkaran
- ..7...-s2.0-S0304405X98000221-mainUploaded bysajidobry_847601844
- How to Face Technical InterviewsUploaded byKrishna Chaitanya
- Daa Queston BankUploaded byharish babu aluru
- Knapsack algorithm java implementationUploaded byAkash
- Distributed ProgrmsUploaded bySanapala Amit
- algorithms and structuresUploaded byLølø
- statreferencesheet.pdfUploaded byChriston John Dela Cruz

- is.7920.1.1994Uploaded byAlexandra Elena Ilinca
- Granular OptimizationUploaded byFrederic Nietzche
- Chapter FiveUploaded byacela3248
- Mathematica Laboratories for Mathematical Statistics (ASA-SIAM Series on Statistics and Applied Probability) (Jenny a. Baglivo) 0898715660Uploaded byIslam Siam
- Chapter 5Uploaded byJunheon Lee
- ASTM Data and ControlUploaded byYohanes Ronny
- Weibull-1960Book-8Uploaded byShane Taylor
- statmat.pdfUploaded byBudi Yanto
- STAT books.txtUploaded byDevid Bita
- Normality Test in ExcelUploaded bySpider Financial
- Univariate Extreme Value Theory-1Uploaded byMaría Sandra Udrizar
- ASTM D 2915 – 98 Evaluating Allowable Properties for Grades of Structural LumberUploaded byalin2005
- Statistics 2008Uploaded byAmeer Bakhsh
- integrating safety stockUploaded byAndry Yanuar
- 05Continuous Univariate Distributions, Vol. 1.pdfUploaded byUsherAlexander
- Nonparametric Statistical Inference (Gibbons; Chakrabort) (4ed.) 2003Uploaded byMinoru Oikawa
- (Atlantis Studies in Probability and Statistics 3) Mohammad Ahsanullah, Valery B Nevzorov, Mohammad Shakil (Auth.)-An Introduction to Order Statistics-Atlantis Press (2013)Uploaded byElíGomaraGil
- IS 7920 Part 1.pdfUploaded byJGD123
- Normal EntropyUploaded byJorge Gonzalez
- D 2915 – 03 ;RDI5MTU_Uploaded byCarlos L. Oyuela
- (Springer Series in Statistics) R.-D. Reiss (auth.)-Approximate Distributions of Order Statistics_ With Applications to Nonparametric Statistics-Springer-Verlag New York (1989).pdfUploaded byNicko Villar
- Lecture 09Uploaded bynandish mehta
- Statistics Assignment Sample 2 with SolutionsUploaded byHebrew Johnson
- 10.1.1.53Uploaded byDwi_Yanti_5542
- The r largest order statistics model for extreme wind speed estimationUploaded byÖnder Umut
- syllabusH2012cUploaded byশর্ট সার্কিট
- E2586.16615Uploaded byCJPATAGAN
- Heavy Rail ModelingUploaded bygiladhaz
- 5. IJAMSS - A New Generalization of the Exponential - Mohieddine RahmouniUploaded byiaset123
- Ch 4 Order StatisticsUploaded bySupraja Niranjan