lpublic
boolean isThere(String item)
l// Assumption: List items are in ascending order
l// Returns true if item is in the list; false otherwise
l{
int first = 0; int last = numItems -
1;
l int middle;
boolean found = false;
l while (last >= first &&
!found)
l { middle = (first + last) / 2;
l if (item.compareTo(listItems[middle]) ==
0)
l
found = true; // Item has been found
l
else if (item.compareTo(listItems[middle] < 0)
l last
= middle - 1; // Look in first half
l
else first = middle + 1; // Look in second half
l }
l return found;
l}