public static void selectionSort(int[] array) { int startScan; int index; int minIndex; int minvalue; for (startScan = 0; startScan < (array.length-1); startScan++) { minIndex = startScan; minValue = array[startScan]; for (index = startScan + 1; index < array.length; index++) { if (array[index] < minValue) { minValue = array[index] minindex = index; } } array[minIndex] = array[startScan]; array[startScan] = minValue; } }

The only way a binary search would work is if it is sorted in acending order so that would be the slection sort, so that would go before the binary search? Also for the binary search why is the last number array.length-1 and not just array.length.

public static int binarySearch(int[] array, int value) { int first; int last; int middle; int position; boolean found; first = 0; last = array.length -1; position = -1; found = false; while (!found && first <= last) { middle = (first + last ) / 2; if (array[middle] == value) { found = true; position = middle; } else if (array[middle] > value) { last = middle -1; } else { first = middle +1; } } return position; }

Thank you