Binary search (2)
To find which (if any) component of the sorted (sub)array a[left…right] equals target:
1. Set l = left, and set r = right.2. While l ? r, repeat: 2.1. Let m be an integer about midway between l and r. 2.2. If target equals a[m], terminate with answer m. 2.3. If target is less than a[m], set r = m–1. 2.4. If target is greater than a[m], set l = m+1.3. Terminate with answer none.