Binary search is an efficient algorithm for finding an item from an ordered list of items. It works by repeatedly dividing in half the portion of the list, until narrowing down the possible locations to just one. The time complexity reduces from O(n) to O(logn).

Table of Content


Iterative

Java

Javascript

Python

Doodle

binary search doodle


Recursive

Java

Javascript

Python

Download Java, JavaScript and Python code
Binary search animated visual