Binary Search
Last updated
Last updated
A searching algorithm that is designed to search from a sorted list.
Idea:
Compare the target with the middle most value
If not found, eliminate the half where the target cannot exist
Cons/Caveat:
The database must be comparable and sortable
First is a binary search and showing how it’d work
Second is a sequential search which is the same as a linear search
We are splitting the dataset continuously into halves until we hit our target or not find our target.
Big O Notation: