Introduction to Algorithms, Second Edition

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

View Full Document Right Arrow Icon
The University of Texas at Austin Lecture 7 Department of Computer Sciences Professor Vijaya Ramachandran Randomized Select CS357: ALGORITHMS, Spring 2006 Randomized Selection The selection problem (Chapter 9) is the following. Input. An array A [1 ..n ]o f n distinct elements from a totally ordered set, andanindex i ,where1 i n . Output. The i th smallest element in array A . If i = 1 the output is the minimum element in the array, and if i = n the output is the maximum element in the array. The median element is the output if n is odd and i =( n +1) / 2. If n is even there are two ‘middle elements’ corresponding to i = n/ 2and i =( n/ 2) + 1; for convenience we will assume that the median is i = d ( n +1) / 2 e , i.e., the upper middle element, when n is even. The selection problem can be solved in O ( n log n ) time using a good sorting algorithm. But it can be solved in O ( n ) expected time using the follow-
Background image of page 1

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

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

This note was uploaded on 01/30/2008 for the course CS 357 taught by Professor Ramachandran during the Spring '06 term at University of Texas at Austin.

Page1 / 2

Lecture 7 - The University of Texas at Austin Department of...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online