What research technique can be used if the array is not sorted?

advertisements

Binary search performs search in O(log n). But, it can be used only if the array is sorted.

Which is the best searching technique if the array is unsorted?


If you're only doing a few searches, then a basic linear search is about the best you can do.

If you're going to search very often, it's usually better to sort, then use a binary search (or, if the distribution of the contents if fairly predictable, an interpolation search).