Overview
Quickselect(A,l,r,k) (find the -th smallest element in )
If then return
else if then return Quickselect(A,l,t-1,k) (Left block)
else then return Quickselect(A,t+1,r,k-t) (Right block)
Time Analysis
Goal: Las Vegas Algorithm with expected run time
We define
# of comparisons
# of calls of Quickselect on elements with
Observation If we choose the middle half of the elements as pivot element, then the search room is reduced by factor at most The search room will be reduced by factor with probability of
Claim: Then (geometric serie ) Proof We also see that the pivot element is one of the middle elements with probability of