Binary Search

October 12, 2022
local_offer Algorithm

Binary Search is a search algorithm.
It requires a sorted collection to make it work.

This search algorithm is simple yet quite powerful.

Performance

The worst-case performance is O(log n).
The best-case performance is O(1).
The average performance is O(log n).

Floor division in Python

To get the midpoint, I needed floor division.
Here is how to write floor division in Python.

mid = low + (high - low) // 2