Binary search is the most popular and efficient searching algorithm having an average time complexity of *O(log N)*. Like linear search, we use it to find a particular item in the list.

Binary search works only on a sorted set of elements. To use binary search on a collection, the collection must first be sorted.

Binary search begins by comparing the middle element of the list with the target element. If the target value matches the middle element, its position in the list is returned. If it does not match, the list is divided into two halves.

The first half…

Arrays are a collection of individual values separated by a comma each with its own index/location. This collection could be anything: numbers, objects, more arrays, etc. In an array, the values, called **elements**, are stored in contiguous memory locations.

This means that all the elements are all in a sequence and they share a common border. The number of elements store in an array is referred to as the array’s **length**.

An array is one of the most efficient ways to store and access a sequence of values or store a collection of data with similar elements. …