BinarySearch
Binary search, as the name implies is to be divided into two pieces of data each time and then to find the data you want, we can think of, the dichotomy to find very similar to our usual guessing price game, when you quote a price, the referee will tell you the price relative to the true value of the high and low, If it is low, then we will certainly say a slightly higher price, and vice versa. The binary lookup requires that the incoming data must be ordered, assuming that it is now ascending, and then each time the value being looked for is compared to the median (the left edge of the array + (right boundary-left boundary)/2), the larger one looks for the median left-hand data, and the lower-right data for the median value.
Algorithm: It is suitable to use this method when the amount of data is large. When searching by binary method, the data need to be ordered and not duplicated.
Given an array of {12, 23, 34, 45, 56, 67, 77, 89, 90}, it is now required to use a dichotomy to find the specified value and return it at the index of the array, or 1 if not found.
Java Fundamentals--two-point method