private void nthElement ( int left , int right , int n , double [ ] origin ) { int npos = partitionItems ( left , right , n , origin ) ; if ( npos < n ) nthElement ( npos + 1 , right , n , origin ) ; if ( npos > n ) nthElement ( left , npos , n , origin ) ; }
Ensures that the n - th element is in a correct position in the list based on the distance from origin .