Problem
The task is to implement a linear time randomized algorithm for the selection problem.
Given: A positive integer and an array of integers from to , a positive number .
Return: The -th smallest element of .
Source: Algorithms by Dasgupta, Papadimitriou, Vazirani. McGraw-Hill. 2006.
任务是为选择问题实现线性时间随机算法。
给定:正整数 和一个数组 来自的整数 至 ,一个正数 。
返回:该的第-个最小元素 。
资料来源:Dasgupta,Papadimitriou,Vazirani的算法。麦格劳-希尔。2006年。
Sample Dataset
11
2 36 5 21 8 13 11 20 5 4 1
8
Sample Output
13