I have this so far:
public int binarySearch(int[] ints, int n) { for(int i = 0; i < ints.length; i++) { if(ints[i] == n) { return ints[i]; } } }
Does this look somewhat correct?
Posted 14 May 2014  06:47 PM
public int binarySearch(int[] ints, int n) { for(int i = 0; i < ints.length; i++) { if(ints[i] == n) { return ints[i]; } } }
Posted 14 May 2014  09:08 PM
Posted 15 May 2014  03:22 PM
Posted 15 May 2014  04:18 PM
public int binarySearch(int[] ints, int n) { selectionSort(ints); int low = 0; int high = ints.length  1; int mid = (low + high) / 2; while(low <= high && (ints[mid] != n)){ if(ints[mid] < n) { low = mid + 1; } else { high = mid  1; } mid = (low + high) /2; } if(low > high) { mid = 1; //returns 1 if n is not in the array of ints } return mid; }
Query failed: unknown local index 'forums_search_posts_main' in search request.
