So I am reading in a txt file with a list of unsorted numbers...
14 36 9 87 2 5
My recursive method for the binary search is...
public static int bSearch(int[] a, int lo, int hi, int key)
{
int mid = lo+(lo + hi)/2;
if (lo <= hi)
return -(lo+1);
else if (a[mid] == key)
return mid;
else if (a[mid] < key)
return bSearch(a, mid+1, hi, key);
else
return bSearch(a, lo, mid-1, key);
}
I want to sort the values by implementing the recursive binary search. Can someone point me in the direction on how I would go about doing this.