Self Check
- Suppose you need to look through a sorted array with
1,000,000 elements to
find a value. Using the binary search algorithm, how many records do
you
expect to search before finding the value?
- Why is it useful that the Arrays.binarySearch method
indicates the position
where a missing element should be inserted?
- Why does Arrays.binarySearch return -k - 1 and
not -k to indicate that a value
is not present and should be inserted before position k?