You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//binary search public static int binarySearch(int[] a , int key){ int lo=0, hi=a.length-1; while (lo<=hi){ int mid = lo+(hi-lo)/2; if (key<a[mid]){ hi=mid-1; } else if (key>a[mid]){ lo=mid+1; } else return mid; } reture -1;}