Implementation of the binary search algorithm