# 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 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 : Find the i-th order statistics of A 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 3/2 n comparisons instead of 2n Minimum-maximum(A)

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.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern