Binary Search Algorithm

Binary search algorithm requires already sorted collection.

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 or the remaining half is empty.

Once the target element found or collection is empty, then the search is over.

Binary Search
Binary Search Explanation
  • Worst-case performance:- O(log n)
  • Best-case performance:- O(1)
  • Average performance:- O(log n)
  • Worst-case space complexity:- O(1)
Java Program Of Binary Search


Key 100 not found Required key:- 50 found at index:- 4

Some theory part of this article uses material from the Wikipedia article “Binary search”, which is released under the CC BY-SA 3.0.

Leave a Reply

Your email address will not be published. Required fields are marked *