Binary Search
/* Given A[0..n] sorted in non-decreasing order, return the subscript of an occurrence of val in A (if val occurs in A) or n+1 otherwise. */
int find(int[] A, int n, int val)
/* Make L==R s.t. if val is in A[0..n], then
/* Reduce the size of the interval A[L..R]
approximately in half, preserving the
property that if val was in the
original interval, then it is in the
return (A[L]==val) ? L : n+1;