Created
April 15, 2014 09:43
-
-
Save klmr/10718254 to your computer and use it in GitHub Desktop.
Binary search implementation for a primitive type in Java.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int binarySearch(int[] arr, int key) { | |
Object[] arrobj = new Object[arr.length]; | |
for (int i = 0; i < arr.length; i++) | |
arrobj[i] = arr[i]; | |
Object keyobj = key; | |
return binarySearch(arrobj, keyobj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment