Package de.tilman_neumann.jml
Class BinarySearch
java.lang.Object
de.tilman_neumann.jml.BinarySearch
public class BinarySearch
extends java.lang.Object
Binary search in bottom-up sorted integer arrays.
-
Constructor Summary
Constructors Constructor Description BinarySearch()
-
Method Summary
Modifier and Type Method Description int
getInsertPosition(byte[] array, int maxIndex, int x)
Find the insert position for x into array given that array is sorted bottom-up.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(java.lang.String[] args)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
BinarySearch
public BinarySearch()
-
-
Method Details
-
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
-
getInsertPosition
public int getInsertPosition(byte[] 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(java.lang.String[] args)
-