When NOT to Use

Avoid forcing this pattern

Avoid forcing this pattern when:

  • Unsorted data without preprocessing: Binary search requires sorted order. If sorting isn't allowed or takes too long, use hash-based approaches.
  • Need all occurrences, not just one: Binary search finds one position.

Finding all requires additional linear scans or multiple binary searches.

  • Small search space: For n < 100100, linear search is simpler and fast enough. Binary search overhead isn't worth it.