# 08 - Order Statistics Data Structures and Algorithms Andrei...

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

Order Statistics Data Structures and Algorithms Andrei Bulatov

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

View Full Document
Algorithms – Order Statistics 8-2 Medians and Statistics We consider the following problems: - Find a minimal and maximal elements in a sequence - Find i-th smallest element in a sequence he allest element of a sequence is called its der statistic The i-th smallest element of a sequence is called its i-th order statistic The median of a sequence of length n is its (n+1)/2-th order statistic, if n is odd n/2 and n/2 + 1-th order statistic In either case, the medians are (n + 1)/2 and (n + 1)/2 -th order statistics
Algorithms – Order Statistics 8-3 The Problem The Selection Problem Instance : A sequence A of n numbers, and i, 1 i n Objective : ind the der statistics of A Find the i-th order statistics of Finding maximum / minimum, median are particular case of the Selection problem Can be solved in O(n log n) by first sorting and then taking the i-th element Our goal is to do this in O(n)

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

View Full Document
Algorithms – Order Statistics 8-4 Maximum and Minimum Finding maximum (or minimum) is easy Minimum(A) set min:=A[1] for i=2 to length(A) do if min>A[i] then set min:=A[i] endfor return min This algorithm runs in O(n) time
Algorithms – Order Statistics 8-5 Maximum and Minimum (cntd) If we need to find both maximum and minimum we can do slightly better that running the algorithm twice: we need

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 11/19/2009 for the course CS CMPT 307 taught by Professor A.bulatov during the Fall '09 term at Simon Fraser.

### Page1 / 16

08 - Order Statistics Data Structures and Algorithms Andrei...

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

View Full Document
Ask a homework question - tutors are online