\begin{algorithm} \caption{Iterative Randomized Select} \begin{algorithmic} \INPUT a sequence $A$ of $n$ elements and an integer $i$ \OUTPUT the $i$-th element of $A$ \STATE $p = 1$ \STATE $r = n$ \WHILE{$p < r$} \STATE $q =$ \CALL{RandomizedPartition}{$A, p, r$} \IF{$q < i$} \STATE $p = q + 1$ \ELSEIF{$q > i$} \STATE $r = q - 1$ \ELSE \RETURN $A[q]$ \ENDIF \ENDWHILE \RETURN $A[p]$ \end{algorithmic} \end{algorithm}