Binary Search Help
Below is the coding for the binary search:
public class Binary_Search_
{
public int binarySearch(int arr[],int key)
{
int low=0;
int high=arr.length-1;
while(low<=high)
{
int middle=(low+high)/2;
if(key==arr[middle])
return middle;
else
if(key<arr[middle]) high=middle-1;
else low=middle+1;
}
return -1;//not found
}}
The only thing is that for the binary search the array must be sorted so what could I add to the start of the coding to quickly sort the array.
You must think this is a simple question but im new to java!>

