Binary search is another fairly efficient way of searching for things. It’s a logarithmic algorithm that relies on having a sorted list. And what you do with binary search is you go to the middle item of this sorted list and if that’s the item you’re looking for then that’s it. If not, you discard half of the items in the list (either from the left or right side depending on whether the current selection is lesser or greater than the search item). You again start in the middle of the new list and keep on repeating this process until you reach your desired search item.
A python programmer and founder of blog.icodes.tech programming blog
Create your free account to unlock your custom reading experience.