 For example, binary search can be used to compute, for a given value, its rank (the number of smaller elements), predecessor (next-smallest element), successor (next-largest element), and nearest neighbor.Range queries seeking the number of elements between two values can be performed with two rank queries.In terms of the number of comparisons, the performance of binary search can be analyzed by viewing the run of the procedure on a binary tree.