public static double selectExcludingZeros ( final double [ ] arr , final int nonZeros , final int pivot ) { if ( pivot > nonZeros ) { return 0L ; } final int arrSize = arr . length ; final int zeros = arrSize - nonZeros ; final int adjK = ( pivot + zeros ) - 1 ; return select ( arr , 0 , arrSize - 1 , adjK ) ; }
Gets the 1 - based kth order statistic from the array excluding any zero values in the array . Warning! This changes the ordering of elements in the given array!