We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What is a Binary Search?

By Rodney A. Crater
Updated: May 16, 2024
Views: 8,646
Share

Suppose a person has a very large assortment of items and arranges them in some orderly way in a long row. That individual can quickly figure out where in the row a particular object is located by using a binary search. This search is done by checking the middle item in the row and if the middle object is not the item sought, thereafter looking in only one of the halves of the row where the item could be. The person would know which half to continue to look in because the items are arranged in order. These two steps are done over and over, on smaller and smaller halves, until the item is either found or there is nowhere left to look.

In the field of computer science, a binary search is a step-by-step procedure that finds the location, or index, of an item in a sequentially sorted set of data. It accomplishes this by comparing a known value to a designated middle element of the array and, if it is not equivalent, repeatedly constraining the middle element comparison to the smaller relevant half of the set until an equivalence is obtained or the list is exhausted.

A binary search, sometimes called a half-interval search, is much faster than a basic sequential search that starts at one end of a list of items and compares each item along the way until a match is found or until the search reaches the end of the list. If a person had 100 items in a row and the last item was the one being looked for, a sequential search would take 100 comparisons. The bisection method, however, requires only seven comparisons at the most before the item is found. It is obviously much more efficient than a sequential search.

The biggest drawback to a binary search is that the list of items has to be sorted for this search to work. Sorting a list takes time. Sorting then using this type of search might take more time than doing another type of search in the first place.

Being able to use information, especially from very large data sets, is important for accomplishing many tasks in life. The discipline of computer science deals with many types of problems, including finding efficient ways to search for information so that useful results are obtained. A binary search is just one of many algorithms available for searching through data.

Share
EasyTechJunkie is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Discussion Comments
Share
https://www.easytechjunkie.com/what-is-a-binary-search.htm
Copy this link
EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.