Probabilistic selection algorithm -
given is:
- an array of length
n
. - the array contains integers.
- the integers not sorted.
find algorithm that:
- returns (a close approximation of)the
k
-th smallest array element. - has runtime complexity of o(
n
logn
) , space complexity of o(logn
). - the algorithm needn't deterministic. in case of probabilistic algorithm provide measure quality of approximated result.
treat problem analogous quicksort. given element in array, can rank in o(n) time , o(lg n) space. can use binary search find element given rank in o(lg n) iterations of that, total of o(lg n) space , o(n lg n) time.
Comments
Post a Comment