Write a new version of lookUp(), called binaryLookUp().
It should have the same parameters and return type as lookUp(), but
it will use binary search. In case you have forgotten, here's some pseudocode:
left = the leftmost index;
right = the rightmost index; //Of the portion of the array that is *used*
found = false;
while (left <= right && found is false)
{
find the middle between left and right;
if (the key equals the name in the middle)
set found to true;
else if (the key is less than the name in the middle)
adjust right so that it's just to the left of the middle
elsea
adjust left so that it's just to the right of the middle;
}
if (found)
return the number at the middle;
else
return "Unlisted number";
}
Implement this pseudocode in binaryLookUp(), and change the
lookUp() method invocation in PhoneOperator so that
it's binaryLookUP(). Many hints for how to do this can already
be found in the original lookUp() method (which I hope you don't
delete).