摘要: 二分查找的实现。算法要求1.必须采用顺序存储结构2.必须按关键字大小有序排列。算法复杂度为o(logn),一般只要被查找的元素大于或等于序列中的最大元素,算法总要执行最大次数的比较。对于一个大小为n的排序数组,算法BINARYSEARCH执行的比较的最大次数为[logn]+1。 1 public class BinarySearch { 2 3 public static int BinarySearchMethod(int[] before,int target){ 4 int low = 0,high = before.length - 1,mid = 0,j =... 阅读全文
posted @ 2012-07-31 22:41 cnlixl 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 基础的java练习,数3退1,数组方式的实现。 1 public class Count3Quit { 2 3 public static void main(String[] args){ 4 5 boolean[] arr = new boolean[500]; 6 int leftCount = arr.length; 7 int count = 0; 8 int index = 0; 9 10 for(int i = 0;i < arr.length;i++){1... 阅读全文
posted @ 2012-07-31 22:37 cnlixl 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 一期项目结束了,不知道为什么莫名其妙的烦躁。可能是一时热血吧,决定写写博客,记录一下自己的生活状态。就当为未来的自己找找乐子吧。 阅读全文
posted @ 2012-07-31 22:29 cnlixl 阅读(115) 评论(0) 推荐(0) 编辑