private static int select(int[] array,int[] index,int left,int right,int k){
  if (left == right) {
    return left;
  }
 else {
    int middle=partition(array,index,left,right);
    if ((middle - left + 1) >= k) {
      return select(array,index,left,middle,k);
    }
 else {
      return select(array,index,middle + 1,right,k - (middle - left + 1));
    }
  }
}

private static int select ( int [ ] array , int [ ] index , int left , int right , int k ) { if ( left == right ) { return left ; } else { int middle = partition ( array , index , left , right ) ; if ( ( middle - left + 1 ) >= k ) { return select ( array , index , left , middle , k ) ; } else { return select ( array , index , middle + 1 , right , k - ( middle - left + 1 ) ) ; } } }
implements computation of the kth - smallest element according to manber ' s " introduction to algorithms " .
