|
I would use binary search. Bear in mind that the number of elements affects the efficiency opposite to the way it affects a sort, too. It's better to combine multiple sets and search the large set than it is to search the smaller sets.
For grins, you could fill the array with values generated by an exponential function and watch the linear interpolation search go to hell in a handbasket. An exponential interpolation would do well though. An example of an interpolative search is the way most people look up a word in the dictionary. The data are amenable, so that's what we use.
|