Algorithm 1 Iterative Randomized Select
Input: a sequence AAA of nnn elements and an integer iii
Output: the iii-th element of AAA
1:p=1p = 1p=1
2:r=nr = nr=n
3:while p<rp < rp<r do
4:q=q =q= RandomizedPartition(A,p,rA, p, rA,p,r)
5:if q<iq < iq<i then
6:p=q+1p = q + 1p=q+1
7:else if q>iq > iq>i then
8:r=q−1r = q - 1r=q−1
9:else
10:return A[q]A[q]A[q]
11:end if
12:end while
13:return A[p]A[p]A[p]