For a nondecreasing sorted array and target , find the unique position such that every earlier value is below and every later value is at least . Equivalently, . Uniqueness follows because, if both satisfied the partition, would have to be both at least and below . A half-open search interval maintains an excluded prefix of smaller values and an excluded suffix of greater-or-equal values. Allowing the sentinel handles an empty array or a target beyond its last entry.
Articles by others on the same topic
There are currently no matching articles.