Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Search {
- public static void main(String[] args){
- int[] x = {};
- double[] y = {};
- }
- public static int recursiveBinarySearch(int[] list, int key){
- int start = 0;
- int end = list.length;
- return recursiveBinarySearch(list, start, end, key);
- }
- public static int recursiveBinarySearch(int[] list, int start, int end, int key) {
- if (start < end) {
- int mid = start + (end - start) / 2;
- if (key < list[mid]) {
- return recursiveBinarySearch(list, start, mid, key);
- } else if (key > list[mid]) {
- return recursiveBinarySearch(list, mid+1, end , key);
- } else {
- return mid;
- }
- }
- return -(start + 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement