













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














Rank of an element is its position in ascending key order.
[2,6,7,8,10,15,18,20,25,30,35,40]
rank(2) = 0
rank(15) = 5
rank(20) = 7
Median score on a test.
Use 3 as the pivot and partition.
rank(pivot) = 5. So pivot is the 6’th smallest element.
Find kth element of:
a 3 2 8 0 11 10 1 2 9 7 1
a 1 2 1 0 2 43 10 11 9 7 8
a 1 2 1 0 2 43 10 11 9 7 8
d (^1)
d (^1)
d (^2)
RA RB
q
q
d
2d
O(n log n) time.
O(n log n) time.