Open In App

Most Asked Binary Search Interview Questions

Last Updated : 08 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Binary search is the most efficient searching algorithm having a run-time complexity of O(log2 N) in a sorted array.

Binary search is a searching technique to search an ordered list of data based on the Divide and Conquer technique which repeatedly halves the search space in every iterationConditions for when to apply Binary Search in a Data Structure:

To apply the Binary Search algorithm:

Whenever we are able to identify that the answer of the problem lies between in a range L to R and there is a Monotonic Behaviour of answer in range L to R then we can think to apply binary search on answer.

Check out this article on how to Identify and Solve Binary search ProblemsView

Question-binary

Binary Search

Top interview questions on Binary search to get hands on ~

Title

Article(Editorial ) Link

Practice Link

Lower and Upper Bound

Read

Solve

Search Insert Position

Read

Solve

Sqrt(x)

Read

Solve

First and Last occurrence of a number

Read

Solve

Search in sorted rotated array

Read

Solve

Search in sorted rotated array II

Read

Solve

Min element in sorted rotated array

Read

Solve

Find peak element in a mountain array

Read

Solve

Koko Eating Bananas

Read

Solve

Allocate Books

Read

Solve

Aggressive Cows

Read

Solve

Minimize max distance to gas station

Read

Solve

Capacity to ship packages within D days

Read

Solve

Median of 2 sorted arrays

Read

Solve

Nth root of a number

Read

Solve

Kth element of 2 sorted arrays

Read

Solve

Find Peak element II

Read

Solve

Find Median in row wise sorted array

Read

Solve

Search in row wise and column wise sorted array

Read

Solve

Complexity Analysis of Binary Search:

  • Time Complexity: 
    • Best Case: O(1)
    • Average Case: O(log N)
    • Worst Case: O(log N)
  • Auxiliary Space: O(1), If the recursive call stack is considered then the auxiliary space will be O(logN).

Check out variants of binary Search :



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads