Binary Search
It’s a search algorithm that is based on the binary tree data structure.
Time Complexity
Average
O(log n)
In the structure, the average height of the tree is O(log n) which means that the search time is about O(log n).
Worst Case
O(n)
It happens when the inserted key is in a increasing or decreasing order, which makes the height of the tree be n.