Binary Search


Introduction and Summary

Binary search is a more specialized algorithm than sequential search as it takes advantage of data that has been sorted. The underlying idea of binary search is to divide the sorted data into two halves and to examine the data at the point of the split. Since the data is sorted, we can easily ignore one half or the other depending on where the data we're looking for lies in comparison to the data at the split. This makes for a much more efficient search than linear search.

Binary search is used on sorted arrays, but we see it more often when used with binary search trees (see the trees SparkNote for more information). Whereas linear search allows us to look for data in O(n) time, where n is the number of elements being searched, binary search allows us to do the same search in O(logn) time, a dramatic speed enhancement.

Binary search is one of the most common search algorithms and is useful in most any real world application you might write.

Take a Study Break

SparkLife

Star Trek gets SEXY

Chris Pine and Zoe Saldana heat up the red carpet!

SparkLife

Are you afraid of relationships?

Auntie SparkNotes can help!

SparkLife

Wanna get JLaw's gorgeous glow?

Click here for simple, sexy makeup tricks!

SparkLife

Sexy starlet style

See every single look from the Met Gala!

SparkLife

Who'd be on your zombie-apocalypse crew?

We already dib'sed Genghis Khan.

Geek out!

The MindHut

Geeky Actors: Then and Now

Travel back in time!

The MindHut

10 Movies Better Than Their Books

What do you think?

The MindHut

How To Look Like J-Law...

When you don't look like J-Law.

The MindHut

12 Scientific Inaccuracies in Into Darkness

What did Star Trek get wrong?

The MindHut

Villains We Want These Actresses to Play

From super cute to super bad!

The Book

Cover image

Read What You Love, Anywhere You Like

Get Our FREE NOOK Reading Apps