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

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

View Full Document Right Arrow Icon
Order Statistics Data Structures and Algorithms Andrei Bulatov
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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)
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

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

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