05 - Deterministic Linear-time Selection

05 - Deterministic Linear-time Selection - Part I: Divide...

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

View Full Document Right Arrow Icon
Part I: Divide and Conquer Lecture 5: Deterministic Linear-Time Selection Lecture 5: Deterministic Linear-Time Selection Part I: Divide and Conquer
Background image of page 1

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

View Full DocumentRight Arrow Icon
Objective and Outline Objective : We discussed a randomized selection algorithm that runs in O ( n ) on average We now discuss a deterministic algorithm that runs in O ( n ) in the worst case Reference : Section 9.3 of CLRS Outline: Idea and Algorithm Analysis of Algorithm Lecture 5: Deterministic Linear-Time Selection Part I: Divide and Conquer
Background image of page 2
Deterministic Selection Algorithm Idea : Question If we follow the Partition idea to solve the selection problem, which step(s) make the worst case running time becomes O ( n 2 )? Ans : We make a “ bad ” split in each iteration Trick : In each iteration, we pick a good element such that it “guarantees” a good split Question How to get such a “good” element in each iteration? Lecture 5: Deterministic Linear-Time Selection Part I: Divide and Conquer
Background image of page 3

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

View Full DocumentRight Arrow Icon
DSelection(A, p, r, i) 1 Divide the n = r - p + 1 items into d n / 5 e sets in which each, except possibly the last, contains 5 items . O ( n ) 2 Find the median of each of the d n / 5 e sets. O ( n ) 3 Take these d n / 5 e medians and put them in another array. Use
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/18/2009 for the course COMP 271 taught by Professor Arya during the Spring '07 term at HKUST.

Page1 / 14

05 - Deterministic Linear-time Selection - Part I: Divide...

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

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