Two-point Search

Source: Internet
Author: User

Find a specific element using the binary lookup method. Requires input array length, input array elements, and keywords to find. The program output is found to be successful, flat, and the output lookup succeeds when the keyword is not specified in the array.

Technical points: Two-point search is binary find, the basic idea is: take the middle position of the record, and to find the key to compare, if equal, then find success. If the key is larger than its size, the element to be searched must be in the right child table, and the right child table will continue to be binary. If key is smaller than it is, the element to be searched must be in the left child table, and the left Dial hand table will continue to be binary-searched. This is recursive until the lookup succeeds or the lookup fails (the lookup range is 0).

One: Source program



Second: Running results



Two-point Search

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.