Searching Sorted Data

Learn about binary search and its most pivotal application.

We'll cover the following

Binary search

The method we used for guessing a number is known as binary search. Perhaps the most important application of binary search is searching sorted data.

Searching sorted data

Searching is a fundamental problem. Given a sequence and an element xx, we would like to check whether xx is present in this sequence. For example, 33 is present in the sequence (7,2,5,6,11,3,2,9)(7,2,5,6,11,3,2,9) and 44 is not present in this sequence. Given the importance of the search problem, it is not surprising that Python has built-in methods for solving it.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.