Sorted But Never Stated

A teammate hands you this helper and asks you to call it from your code.

def first_at_least(a, x):
    """Return the smallest index i with a[i] >= x,
    or len(a) if every element is smaller than x.

    Runs in O(log n).
    """

The docstring never uses the word "sorted". Which obligation does the caller nevertheless have to satisfy, and what in the docstring is the only clue that it exists?

A

len(a) must be a power of two so that the interval can be halved evenly at every step.

B

a must be sorted in non-decreasing order, and the O(log⁡n)O(\log n) line is the only clue. Nothing in the described behaviour needs sorting: a linear scan returns the same index with no precondition at all.

C

x must already appear somewhere in a, otherwise the search has nothing to converge on.

D

a must contain no duplicate values, since two equal elements make the returned index ambiguous.