Binary search (7)
static int binarySearch (Comparable target, Comparable[] a, int left, int right) {// Find which (if any) component of the sorted (sub)array // a[left…right] equals target. int l = left, r = right; while (l <= r) { int m = (l + r)/2; int comp = target.compareTo(a[m]); if (comp == 0) return m; else if (comp < 0) r = m - 1; else l = m + 1; } return NONE;}