Package de.tilman_neumann.jml
Class BinarySearch
- java.lang.Object
-
- de.tilman_neumann.jml.BinarySearch
-
public class BinarySearch extends Object
Binary search in bottom-up sorted integer arrays.- Author:
- Tilman Neumann
-
-
Constructor Summary
Constructors Constructor Description BinarySearch()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getInsertPosition(int[] array, int maxIndex, int x)
Find the insert position for x into array given that array is sorted bottom-up.static void
main(String[] args)
-
-
-
Method Detail
-
getInsertPosition
public int getInsertPosition(int[] array, int maxIndex, int x)
Find the insert position for x into array given that array is sorted bottom-up. More precisely: If array[maxIndex-1] > x, return the index of the first entry of array[0].. array[maxIndex-1] greater than x. If array[maxIndex-1] <= x, return maxIndex.- Parameters:
array
-maxIndex
- the maximum index to consider, exclusive (may be smaller than the array size)x
-- Returns:
- the insert position
-
main
public static void main(String[] args)
-
-