DEV Community

Alen Abraham Oghenero
Alen Abraham Oghenero

Posted on

Comparism between The binary search algorithm and the logarithmic algorithm.

BINARY SEARCH ALGORITHM
Binary search is also known as Half-interval search. It 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.
In Binary Search, we repeatedly divide the “sorted data” in half until we are left with just one element, or the search element is found. The Big O notation for Binary search algorithm is O(n). Binary search algorithm can be used to perform exact matching and set membership ( determining whether a target value is in a collection of values).

LOGARITHMIC ALGORITHM
An algorithm is said to be logarithmic when its time of execution is proportional to the logarithm of input size. The Big O notation for logarithmic algorithm is O(log n). Logarithmic algorithm are algorithm where processing discard a large number of values in each iterations.

The Binary search algorithm is a form of logarithmic search algorithm.

Top comments (0)