This article is about the search for ordered tables, which mainly includes the optimization usage of sequential lookups, binary lookups, interpolation lookups, Fibonacci lookups;
Sequential Optimization Search : The efficiency is very low, but the algorithm is simple, suitable for small data search;
Binary lookup : Also known as a binary lookup, it is searched from the middle of the lookup table. Finding results requires only half of the data records to be found. Efficiency is much better than sequential lookups. The comparison is applicable to static tables, which are not changed after a single order;
interpolation lookup : Similar to binary lookup, just the middle mid's formula is transformed to MID = (Low+high)/2; mid = low + (high-low) * (Key-sum[low])/(Sum[high]- Sum[low]);
The efficiency of interpolation finding is much higher than that of binary, and it is more suitable for the table with larger size and more uniform distribution of the keywords.
Fibonacci Lookup : Is the use of the Golden section of the principle to find, the average performance is better than binary lookup, but if the worst case, then the efficiency of less than binary lookup (to find the keyword has been relatively close to the golden segment of the longer paragraph), but is a simple operation, only the simplest addition and subtraction operation;
Code implementation:
An ordered table lookup of Java data structures