Articles Golf
  • Home
  • Business & Trade
  • Home Improvement
  • Game & Sport
  • Politics and Legal
  • Services
  • Contact
No Result
View All Result
  • Home
  • Business & Trade
  • Home Improvement
  • Game & Sport
  • Politics and Legal
  • Services
  • Contact
No Result
View All Result
Articles Golf
No Result
View All Result
Home Computers and Technology

Binary Search: Real-Life Examples

Lindsay by Lindsay
December 27, 2021
in Computers and Technology
0
What is binary search
0
SHARES
61
VIEWS
Share on FacebookShare on Twitter

Searching for an item is a common task in computer science as well as in our daily life. When we are trying to find something fast, choosing the right type of search method is the key. For instance, when locating a specific element among numerous sorted elements in a huge dataset, binary search is the most efficient one. New to search algorithms and want to know how binary search work in real life? From what I’ve learned from algo.monster, I will show you some real-life examples of this approach in this post.

Before presenting the examples of binary search applications, the first step is to figure out what exactly it is.

What is binary search?

A binary search algorithm works by comparing two elements each time and eliminating half the elements. And the search procedure always starts with the comparison between the target and the middle value in the array.

 

The best case is when the middle value is exactly what you’re looking for. Therefore, the search ends with the first step. Otherwise, it goes as the following two ways.

If the middle element of an array tends to be greater than the target value. Then, it searches the lower half of the array which is usually the left half (in ascending order). However, if the middle element is smaller, it will select the higher part of the two halves and keep on searching.

Then, the algorithm will repeat the process in the same way until the number of elements in the array becomes 1 or 2. Then, it returns the index of the item or -1 if the element happens to be absent from the original array.

The efficiency of binary search

This kind of search algorithm is famous for its efficiency in dealing with large data. The time complexity of it is O (log n) in the worst case.

During the search process, the technique downsizes the list by half after each comparison. Obviously, the search space goes like a half, then a quarter, then one out of eight, and so on. As a result, it is much faster than most algorithms.

Yet, you should know that this technique has one limitation: it won’t work with unsorted data. In other words, you can only deal with order data using it.

The efficiency of it can be perfectly shown in the worst case. Suppose the target will be the last element that you spot using binary. Say we have 100,000 elements in an ordered database. What’s the most comparisons should it go through before checking all the elements? 20.

Sounds great? And it’s more obvious when you compare the worst case of using linear search which will be 100,000 times of comparisons.

Real-life examples of binary search

Now, let’s look at some of the common examples of binary search in real life.

Dictionary

The English language contains thousands of words. And it is impossible to remember all the words. Therefore, we need a dictionary to store all the words. And dictionaries help us to find the meanings of words.

A dictionary is essentially a collection of words in alphabetic order. In other words, this is a list of well-sorted elements.

How do we look for a new word using binary search?

Let’s say we want to find the meaning of “Binary”. You can search for the word by reading the dictionary word-by-word from the beginning and comparing it with the word you are looking for. For sure, you can find this word maybe in an hour or so. Thus, this way can be time-consuming and tiresome.

Well, you can simplify this mission by using binary search. This time, you open approximately from the middle of the dictionary. Then, check what letter the letters on that page start with. Suppose you are on the page where letters begin with M. B is alphabetically smaller than M. So, you certainly won’t keep searching this word from the upper side-letter starts with N to Z.

One more thing, in this case, since B is the second letter in the alphabet, we normally automatically open it from the lower half of the dictionary. More specifically, we will try opening the page very close to the beginning.

Students’ height

Let’s say you need students to attend some activity that requires someone taller than 5 feet. And suppose students don’t know their heights.

Although you have a measurement instrument, measuring each student’s height takes much time. Again, you can use binary search to optimize the measuring process.

Firstly, ask the students to stand in line in increasing order in terms of height. In other words, the one that stands behind is taller.

Let’s say here’re the heights of them:

(4.2) (4.5) (4.7) (5.1) (5.1) (5.2) (5.3) (5.5) (5.6) (6)

How do you determine the height using binary search?

So, here’s how you pick the one to measure first. Check out the height of the student who stands in the middle.

(4.2) (4.5) (4.7) (5.1) (5.1) (5.2) (5.3) (5.5) (5.6) (6)

First measurement using binary search: student in the middle is 5.1. 5.1>5, so, you go left and spot the middle which is 4.7. Then, you go right, and only measure the students between these two students: one is 4.7 and the other is 5.1. Again, another 5.1, which means two students are 5.1 and the students behind the 4th in the line are all above 5 feet.

So, you don’t need to measure every student with binary search.

Library

This case is similar to finding a new word in the dictionary. It is impossible to search for a book in a linear fashion which goes through all thousands of the books on the shelves.

Since all books are put on the shelves alphabetically. Binary search is applicable.

Conclusion 

Binary search is an efficient yet simple search method. You can use it in daily life though sometimes you don’t even notice that you’re using such a technique.

When you are looking for a name through the phonebook. You never start with the first page if the name starts with the letter K. Normally, we tend to open it in the middle and search, move lower or higher.

Post Views: 831
Tags: binary search
Lindsay

Lindsay

Related Posts

Hotel systems integrators
Business & Trade

How Hotel Systems Integrators and Property Management Systems Help Hotel Businesses

December 26, 2024
Computers and Technology

The Top 5 Work Shift Schedule Generators for Small Businesses

December 21, 2024
M Tech
Computers and Technology

Revolutionizing Customer Support: How AI-Powered Chatbots Are Transforming Australian Businesses

September 14, 2024
Next Post
small business loan

Business Loans for the Service Sector

book online lab test in Pakistan

What is Cystic fibrosis? Its symptoms, causes and treatment

Lab Equipment Management Software

Best Lab Equipment Management Software

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

Categories

  • Automotive
  • Banking & Finance
  • Biography
  • Business & Trade
  • Computers and Technology
  • Digital Marketing
  • Family and Relationship
  • Fashion & Lifestyle
  • Featured
  • Food and Drink
  • Gadgets & Accessories
  • Game & Sport
  • General
  • Health and Medical
  • Home Improvement
  • Movie and Entertainment
  • News and Society
  • Pets and Animals
  • Politics and Legal
  • Real Estate
  • Reference and Education
  • Services
  • Travel and Leisure

Highlights

The Ripple Effect: Custom Gummy Manufacturing & Our Environment

How Hotel Systems Integrators and Property Management Systems Help Hotel Businesses

The Top 5 Work Shift Schedule Generators for Small Businesses

Berani Bertaruh: Mengenal Risiko dan Manfaat Bermain slot online.

Why Hiring a Reputable Lawyer is Crucial for Your Walkerton Court Case

Insights Into the Rapid Growth of Industrial Space in Florida Commercial Real Estate by Lawrence T Maxwell

Trending

geospatial services company
Services

Mapping the Future: Exploring the Impact of Geographic Solutions on Australian Infrastructure

by Articles Golf
June 9, 2025
0

Australia, a land of vast landscapes and ambitious infrastructure projects, is increasingly relying on the power of...

leaking balcony repairs Perth

Leaking Balcony Repairs Perth? Here’s How to Solve Them

June 4, 2025
Australia tour packages

A Guide to Exploring Australia’s World Heritage Sites

January 18, 2025
custom gummy manufacturing

The Ripple Effect: Custom Gummy Manufacturing & Our Environment

January 18, 2025
Hotel systems integrators

How Hotel Systems Integrators and Property Management Systems Help Hotel Businesses

December 26, 2024

ARTICLES GOLF

Welcome to Articles Golf. Our team of experts writes quality content about General niches. Produce relevant, engaging, informative samplings of top News for Visitors. Articles Golf produces highly ranked links to major search engines.

For Contact Us at:

support@articlesgolf.com

For Business Inquiry:

articlesgolfsite@gmail.com

© 2018 All Rights Reserved By Articles Golf

No Result
View All Result
  • Home
  • News and Society
  • Business & Trade
  • Fashion & Lifestyle

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

koi finance