top of page
Writer's pictureVikram Nayyar

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:




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!!!



  • computerscience

  • code

  • coder

  • coding

  • codinglife

  • compandcode

  • computer

  • developer

  • html

  • java

  • javascript

  • machinelearning

  • programmer

  • programming

  • python

  • softwaredeveloper

  • softwareengineer

  • tech

  • technology

  • webdeveloper



  • code

  • coder

  • coding

  • codinglife

  • compandcode

  • computer

  • computerscience

  • developer

  • html

  • java

  • javascript

  • machinelearning

  • programmer

  • programming

  • python

  • softwaredeveloper

  • softwareengineer

  • tech

  • technology

  • webdeveloper

88 views1 comment

Recent Posts

See All

1 Comment


Jamie
Feb 01, 2021

Super useful for the syllabus thanks!

Like
bottom of page