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).

binary search doodle

Table of Content


Iterative

Java

Javascript

Python


Recursive

Java

Javascript

Python

Download Java, JavaScript and Python code
Binary search animated