import static org.junit.Assert.*;import org.junit.Test;public class SearchAlorithms { /** * 二分查找算法 从start到end(包括start和end)之间的所有数中找到n * @param a * @param n * @param start * @param end * @return */ static int binarySearch(int[] a, int n, int start, int end) { while (start <= end) { int mid = (start + end) / 2; if (n < a[mid]) end = mid; else if (n > a[mid]) start = mid + 1; else if (n == a[mid]) return mid; } return -1; }}