After having searched the internet I was not able to satisfy myself that I had found a comprehensive set of situations in which a linear search would be preferable to a binary search.
I am essentially wondering whether it would be possible to compile a relatively definitive list of advice (from the point of view of general programming as one might find in industry). Alternatively I would much appreciate it if it could be verified that indeed I have seen all there is to say on the subject.
My list of reasons for choosing a linear search over a binary search are as follows:
The list is unsorted and is only to be searched once
The list is small (though this itself is a vague notion - I've read less than around 100 elements?)
The list will need sorting following the search operation (due to say an insertion), since the resorting will dominate the time complexity of the overall task
The data structure is not random access (like a linked-list)
There is no knowledge of the data that could aid searching (relative proximities?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With