标签:lse tps log search 常用 http htm 二分 归并
1 二分查找:
非递归 public static int biSearch(int []array,int a){ int lo=0; int hi=array.length-1; int mid; while(lo<=hi){ mid=(lo+hi)/2; if(array[mid]==a){ return mid+1; }else if(array[mid]<a){ lo=mid+1; }else{ hi=mid-1; } } return -1; } 递归实现: public static int sort(int []array,int a,int lo,int hi){ if(lo<=hi){ int mid=(lo+hi)/2; if(a==array[mid]){ return mid+1; } else if(a>array[mid]){ return sort(array,a,mid+1,hi); }else{ return sort(array,a,lo,mid-1); } } return -1; }
快速排序:参考 https://www.cnblogs.com/coderising/p/5708801.html
堆排序:https://www.cnblogs.com/chengxiao/p/6129630.html
归并排序:https://www.cnblogs.com/chengxiao/p/6194356.html
标签:lse tps log search 常用 http htm 二分 归并
原文地址:https://www.cnblogs.com/Samuel-Leung/p/10885811.html