Skip to content

Files

Latest commit

243be8f · Dec 4, 2018

History

History
This branch is 169 commits behind trekhleb/javascript-algorithms:master.

binary-search

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Apr 16, 2018
Jul 18, 2018
Dec 4, 2018

Binary Search

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.

Binary Search

Complexity

Time Complexity: O(log(n)) - since we split search area by two for every next iteration.

References