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 sort; public class QuickSort { public static final int cutoff = 3; /** * insertion sort * * @param A * @param left * @param right */ public static void insert_sort(int[] A, int left, int right) { for (int p = left; p <= right; p++) { int tmp
定一个基准位,递归左右两边排序. public void fun(){ int arr[] = {2,3,4,5,6,7,822,3,4,5,8,6,5,4,2,1}; //System.out.println(qsort(arr,0,(arr.length)-1)); dofun(arr,0,(arr.length)-1); for(int i = 0 ; i < arr.length ; i ++){ System.out.println(arr[i]); } } private int q
选择排序: 简述:从数组的第一个元素开始,依次与其他所有的元素对比,如果比自身大或小(取决于升序或降序)交换位置. 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
链表文件 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(
一.快排的一种 ==================== public class myMain { public static void main(String[] args) { int t[] = {2,6,7,8,5,4},low,high; low = 0; high = t.length-1; allSort(t,low,high); for(int t1:t){ System.out.print(t1); } } public static void allSort(int[] t