标签:
array = [1,2,3,6,5,4] for i in range(len(array)): for j in range(i): if array[j] > array[j + 1]: array[j], array[j + 1] = array[j + 1], array[j] print array
3、选择排序【数组长度为N时,循环N-1轮】
4、二分法查找算法【折半查找算法】,在数组中查询某个元素,前提是该数组已经排序
算法:
int[] arr = {1,5,9,12,16,56,89,99};
int begin = 0;
int end = 7;
int mid = (begin + end) / 2
mid =3;
arr[3]<56;
begin = mid + 1;
end = 7;
mid = 5;
arr[5]=56;
标签:
原文地址:http://www.cnblogs.com/zhuiyiyujinxiang/p/4619672.html