Binary Search Preconditions
The fundamental precondition is that the search space must have an ordering that allows half of the candidates to be safely discarded after each comparison. For the standard array implementation, this means the data must be sorted according to the same ordering used by the comparison.
Data must be sorted or otherwise monotonically ordered.
The comparison must be consistent with that ordering.
Random access is important for efficient array-based binary search.
Time complexity is O(log n).