Here's All You Need to Know About the Binary Search Algorithm!!!

Intro:

So I've already posted code on GitHub about the Binary Search Algorithm and I've made infographics about it too so what better to do than write a blog post about it!!!


I'm going to talk about this algorithm from the perspective of someone who has used it at GCSE and A Level and is now at university. This means I'll give you the key information, without overloading or adding unnecessary complexity.


Before I get into this post, I just want to SHOUT OUT James for recommending that I talk about this algorithm, in a blog post!!


As always, make sure you like, and share and be sure to leave a comment too ! I'd love to know your thoughts. And if you want to support TheNibbleByte and me as a creator then make sure you click the ads!


ENJOY!!



Theory:

Takes an ordered list.

Define where the first value is (lowest); where the last value is (highest); the midpoint ;and the number we're looking for (target).

If the target is less than the midpoint then the second half of the list (greater than the midpoint) is discarded.

The algorithm is then called again and again until the target is left.

By discarding sub-lists, it means that each iteration is shorter because each sub-list is smaller.


Implementation:



Credits: https://www.github.com/compandcode


Advantages:

Eliminates half of the list after each iteration, making it fast. This makes it appropriate for larger data sets.

Disadvantages:

Requires the list to be sorted therefore it doesn't work on everything. Also means a sorting algorithm has to be applied first before searching.

For small datasets, the time saving may not actually be that significant.

Final Things:

As always, thank you for making it this far, please leave comments, they help me so much. Be sure to like and share also, lets try and get 100 views within a week, like we have done previously. Follow CompAndCode on all platforms! Thank You Nibble Byte!!!

Hashtags: #computerscience #coding #programming #technology #python #programmer #computer #tech #developer #coder #java #javascript #code #codinglife #webdeveloper #softwareengineer #engineering #machinelearning #softwaredeveloper #html #programmers #software #artificialintelligence #computerengineering #linux #datascience #cybersecurity #programmingmemes #hacking<