One-dimensional array of Java arrays binary find BinarySearch

Source: Internet
Author: User

http://www.verejava.com/?id=16992676834929

/* Using dichotomy: Find the index position of the given value from an already sequenced array scores: 1. Initialize the lowest bit low=0 first, the highest bit high=scores.length-1 2. Find the median mid= (low+high)/2 value Scores[mid] 3. Compare median scores[mid] to value if the Scores[mid]==value description is found to print the current index of mid, if Scores[mid]<value describes the value to find in mid+1 to H Between IgH if Scores[mid]>value indicates that the value to find is between low and mid-1 4. And so on, the loop performs 3 steps until the value is found or the low>=high termination loop is not found */import Java.util.scanner;public class arraybinarysearch{public STA        tic void Main (string[] args) {//define an already ordered fractional array int[] scores={30,40,50,70,85,90,100};        System.out.println ("Please enter the value to look for:");        Scanner in=new Scanner (system.in);        int Value=in.nextint (); 1.        First initialize the lowest bit low=0, the highest bit high=scores.length-1 int low=0;        int high=scores.length-1;        int mid=0;        Boolean isfind=false;            while (Low

http://www.verejava.com/?id=16992676834929

One-dimensional array of Java arrays binary find BinarySearch

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.