Python implementation binary Search

Source: Internet
Author: User
* binary search is binary find

For example, 12345 of these numbers to find 2, he will first find the backbone of the five numbers of the one and 2 to compare,
For example, in the middle of 3 "2 he thought 3 after the need not to find, and then find 3 left, that is, 123, and then divide this half,
Then the backbone for 2,2=2 is found
In fact, the code is the idea, but this inside adds a recursive call function.

Talk about the problem: recursive calls up to 999 default,
The beginning of the time did not write if the search is finished or not, how to do,
Code is not difficult is a recursive call thought, I am also just contact, there are problems to discuss together, welcome

Python implementation binary Search

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.