An ordered table lookup of Java data structures

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.