Problem
1. 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?
2. What is the "light bulb pattern" of visits in the following algorithm to check whether an array is a palindrome?
for (int i = 0; i< a.length/2; i++)
{
if (a[i] ! = a[a.length - 1 - i]) {return false;}
}
return true;