Skip to main content

Identifying the binary search pattern


The binary search algorithm is one of the most powerful search algorithms that is used to solve many types of search and optimisation problems involving a sorted search space. These are generally easy or medium problems where we need to search for a value in a sorted sequence. Most of the time, searching is often a subproblem within a larger, more complex problem.

Binary search is used to search for a value in a sorted search space.

If the problem statement or its solution follows the generic template below, it can be solved by applying the binary search algorithm.

Template:
Given a sorted search space and a target value, find the target value.

Example

Let's consider the following problem as an example to better understand how to identify and solve a problem using the binary search algorithm.

Liking the course? Check our discounted plans to continue learning.