Skip to content

Resource · Guide or article

Binary Search

Short definition of binary search on a sorted array, the starting point for many halving-style interview problems.

Reviewed

Open the original: Binary Search (opens the original site in a new tab)

Practice this topicOpens the practice interviewer with a question on Binary search.

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

Read this in other languages: Português brasileiro. Español. In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. If the search ends with the remaining half being empty, the target is not in the array. Time Complexity: O(log(n)) - since we split search area by two for every next iteration.

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Reference

What it covers

  • How each comparison with the middle element discards half the remaining range.
  • What happens when the remaining range is empty: the target is absent.
  • Time complexity stated as O(log(n)).

How to use it

PrepKit study advice, not a claim made by the source.

Write iterative and recursive versions, then test an empty array, one element, and a missing target.

Scope and limitations

Very brief: no off-by-one discussion, no lower or upper bound variants, and no practice problems. Links to Wikipedia and YouTube. Portuguese and Spanish versions exist.

Access and format

English README, free on GitHub (trekhleb/javascript-algorithms, MIT).

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/algorithms/search/binary-search/README.md

Related preparation

These are PrepKit study suggestions, not employer endorsements or predictions of interview questions.

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email