算法
奇迹时代3
这个作者很懒,什么都没留下…
展开
-
选择排序
//选择排序 实现 public static void selectSort(int[]arr) { for(int i=0;i int minIndex=i; for(int j=i+1;j if(arr[j] minIndex=j; } } if(minIndex!=i){ int temp=arr[i]; arr[i]=arr[minIndex]; arr[mi原创 2017-07-13 22:01:17 · 307 阅读 · 0 评论 -
插入排序(Insertion Sort)
写点东西总结一下,朋友们,你们也自己写写东西总结一下,这样有助于我们记住一些东西 先把代码贴出来 public static void selectSort(int[]arr) { int temp; for(int i=0;i for(int j=i+1;j>0;j--){ if(arr[j] temp=arr[j-1]; arr[j-1]=arr[j]; arr[j]原创 2017-07-13 22:26:05 · 209 阅读 · 0 评论 -
希尔排序(Shell Sort)
这个排序看起来比冒泡选择,插入都难,逻辑复杂一些。 凭直觉啊,就知道这个不简单,有点怕怕。 没有办法,给自己心理一个暗示,一定要看完这8个基本排序算法的,慢慢来吧。 java代码实现: public static void shell_sort(int array[],int lenth){ int temp = 0; int incre = lenth; while(转载 2017-07-13 22:52:41 · 217 阅读 · 0 评论 -
算法把rootview中所有的button改变背景
if (view == null || !(view instanceof ViewGroup)) return; Stack m = new Stack while (view != null) { ViewGroup tmpGroup = (ViewGroup) view; int count = tmpGroup.getChildCount(); for (int i =转载 2017-07-14 09:09:57 · 219 阅读 · 0 评论 -
快速排序
/** * 快速排序 * 先从数列中取出一个数作为key值; 将比这个数小的数全部放在它的左边,大于或等于它的数全部放在它的右边; 对左右两个小数列重复第二步,直至各区间只有1个数。 * @param a * @param l * @param r */ public static void quickSort(int a[],int l,int r){ if(l>=r)翻译 2017-07-24 22:19:38 · 168 阅读 · 0 评论 -
基数排序
基数排序(RadixSort) BinSort BinSort想法非常简单,首先创建数组A[MaxValue];然后将每个数放到相应的位置上(例如17放在下标17的数组位置);最后遍历数组,即为排序后的结果。 问题: 当序列中存在较大值时,BinSort 的排序方法会浪费大量的空间开销。 基数排序是在BinSort的基础上,通过基数的限制来减少空间的开销。 (1)首转载 2017-07-25 21:55:28 · 227 阅读 · 0 评论