Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

Welcome to Interviewbit, help us create the best experience for you!

Currently, You are a:

Few details about your education

College/University *
Enter the name of your college
Branch *
Year of completion *

Few details about your education

College/University *
Enter the name of your college
Branch *
Year of completion *

Few details about your career...

Current Company *
Enter company name
Experience *

You're all set!

Begin your success journey!

Sign Up using
Full name *
Email *
Password *

By creating an account, I acknowledge that I have read and agree to InterviewBit’s Terms and Privacy Policy .

Welcome back!

Log In using
Email *
Password *

Binary Search

Go to Problems

Level 1

Jump to Level 2

Level 2

Jump to Level 3

Level 3

Jump to Level 4

Level 4

Jump to Level 5

Level 5

Jump to Level 6

Level 6

Jump to Level 7

Level 7

Jump to Level 8

Level 8

Be a Code Ninja!

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

Binary search begins by comparing the middle element of the list with the target element. If the target value matches the middle element, its position in the list is returned. If it does not match, the list is divided into two halves. The first half consists of the first element to the middle element whereas the second half consists of the element next to the middle element to the last element i.e. the search interval is repeatedly divided into halves.

Let's take an example and see how binary search works and number of steps it takes as compared to linear search.

 

Binary Search example 

 

Serious about Learning Programming ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum which covers Data Structures & Algorithms in depth.

Binary Search Problems

Simple binary search
Search answer
Problem Score Companies Time Status
Matrix Median 225 77:24
Square Root of Integer 275 40:32
Allocate Books 350 68:01
Painter's Partition Problem 350 81:38
Red Zone 400
50:08
Search step simulation
Problem Score Companies Time Status
Implement Power Function 275
59:44
Simple Queries 300
64:28
Sort modification
Problem Score Companies Time Status
Median of Array 325 87:05
Rotated Sorted Array Search 325 56:53

Additional Practice

Problem Score Companies Time Status
Capacity To Ship Packages Within B Days 200 33:18
Free Mock Assessment
Help us know you better for the best experience
Current Employer *
Enter company name
College you graduated from *
Enter university name
Phone Number *
OTP will be sent to this number for verification
+91
+91
Change Number
Edit
Resend OTP
By clicking on "Continue" I agree to be contacted by Scaler in the future.
Already have an account? Log in