快排说的很邪乎,原理懂了,实现自然也就出来了: public void static quickSorted( int[] a ,int low ,int high){ //递归结束条件 if(low>=hih){ return ; } int i=low; int j=high int base=a[low]; int temp=0; while(i<j){ while(i<j&&a[j]>base){ j--; } while(i<j&&
链表文件 package sort; public class SqList { public int LIST_INIT_SIZE = 8;//链表的原始大小 private int INCREMENT = 1;//链表的增量大小 private Object[] SqList = null;//链表 private int curIndex = 0;//当前位置 /** * 初始化链表 * */ public void initList(
import java.util.Arrays; public class QuickSort { //三数取中法.取出不大不小的那个位置 public static int getPivotPos(int[] a,int low,int high) { int mid=(low+high)/2; int pos=low; if(a[mid]<a[low]) { int temp=a[low]; a[low]=a[mid]; a[mid]=temp; } if(a[high]<a[low])
选择排序: 简述:从数组的第一个元素开始,依次与其他所有的元素对比,如果比自身大或小(取决于升序或降序)交换位置. package com.sort; import java.util.Arrays; /** * 选择排序 */ public class ChiceSort { public static void chiceSort(int[] array) { int sum = 0; for (int i = 0; i < array.length - 1; i++) { for (int