1.Denote
the subscript of the first item in the
list by first and the subscript of the last item by last.
Initially, the value of first is 1,
the value of last is the number of items in the list, and the value of flag is
False.
2.Look
at the middle item of the current list, the item having the subscript
middle = Int((first + last ) / 2)
3.If
the middle item is quarry (what you are
looking for), then flag is set to True and the search is over.
4.If
the middle item is greater than quarry, then quarry should
be in the first half of the list. So the subscript of quarry must lie between first and middle - 1.
That is,the new value of last is middle - 1.