public static double select ( final double [ ] arr , int lo , int hi , final int pivot ) { while ( hi > lo ) { final int j = partition ( arr , lo , hi ) ; if ( j == pivot ) { return arr [ pivot ] ; } if ( j > pivot ) { hi = j - 1 ; } else { lo = j + 1 ; } } return arr [ pivot ] ; }
Gets the 0 - based kth order statistic from the array . Warning! This changes the ordering of elements in the given array!