Computer Applications

A binary search of an ordered set of elements in an array is always faster than a sequential search of the elements. True or False ?

Java Arrays

3 Likes

Answer

False

Reason — In a case where the search item is at the first place in a sorted array, sequential search becomes faster than binary search as the first comparison yields the desired value. In case of binary search, the search value is found after some passes are finished.

For example, let us consider an array arr[] = {2, 5, 8, 12} and the search value = 2. In this case, sequential search will find the search value in the first comparison while binary search will first compare the search value with the mid value i.e. 5 and continue its passes.

Answered By

2 Likes


Related Questions