9.2-3
Write an iterative version of RANDOMIZED-SELECT
Analyse:
For this the original recursive algorithm, the recursion doesn't need to remember the intermediate information, ie. there is no combine process of the divide-conquer-combine paradigm. So i think the the iterartive version is more efficient regarding memory use.
Implementation:
Iteratively adjust the r and q and i on the original array.
Iterative-Randomized-Select (A, p, r, i)
while( p != r){
q = random-partition(A, p, r);
k = p - p + 1;
if( i == k){
return A[k];
}else if ( i