Which of the following is a real-world application of binary search?
Practice Questions
Q1
Which of the following is a real-world application of binary search?
Finding a name in a phone book
Sorting a list of numbers
Traversing a tree
Inserting an element in a queue
Questions & Step-by-Step Solutions
Which of the following is a real-world application of binary search?
Step 1: Understand what binary search is. It is a method used to find an item in a sorted list by repeatedly dividing the search interval in half.
Step 2: Think about a phone book. A phone book is a list of names that is sorted alphabetically.
Step 3: When you want to find a name in the phone book, you don't start from the beginning and look at every name one by one.
Step 4: Instead, you open the phone book in the middle and check if the name you are looking for is before or after that middle name.
Step 5: Depending on the result, you then only look in the half of the phone book that could contain the name.
Step 6: You repeat this process, each time cutting the number of names you need to check in half, until you find the name or determine it is not there.