For sorted arrays, the binary method is a simple and effective search method. The algorithm complexity is O (log2n). Code: [java] package alg; public class Bisection {public static int bisectionSearch (int value, int [] array) {int minIndex = 0; int curIndex = 0; int maxIndex = array. length-1; int count = 0; // used for calculating the number of cycles int result =-1; if (value = array [maxIndex]) {result = maxIndex ;} else if (value = array [minIndex]) {result = minIndex;} else {while (true) {// if both Same or adjacent. Because the values (except for the first time) of the two come from a value that has been compared with the value, this value is not in the array. If (2> maxIndex-minIndex) {result =-1; break;} curIndex = minIndex + (maxIndex-minIndex)/2; if (array [curIndex] = value) {result = curIndex; break;} else if (array [curIndex] <value) {minIndex = curIndex;} else {maxIndex = curIndex;} count ++;} System. out. println ("loops =" + count); return result;} public static void main (String [] args) {int num = 1000; int value = 0; int [] array = new int [num]; for (int I = 0; I <num; I ++) {array [I] = I;} www.2cto.com System. out. println ("value =" + value + "at index" + bisectionSearch (value, array) + "of array. ") ;}} Author: Pirate Leoblog: http://blog.csdn.net/pirateleoemail:codeevoship@gmail.com