34.8k views
4 votes
When would a linear search be preferable over a binary search?

User Beaumind
by
5.9k points

1 Answer

3 votes

Answer:

linear search be preferable over a binary search because In binary search the input data must be sorted before searching but in linear search input data need not to be sorted .

As input data need not to be sorted in linear searching so the complexity of linear sorting is O(n) but in binary search if input data is not sorted then firstly be sorted the data then after that it perform searching so the complexity of binary search if input data is not sorted is O(nlogn+logn)

Their are some important points linear search over binary search

linear searches searches the data linearlly so it perform equality comparison and binary searches the data randomly so perform ordering comparison.

User Roberto Attias
by
6.2k points