class ArraySort
{
private long[] a;
private int nElems;
private long compCount;
private long changeCount;
public ArraySort(int max) {
a = new long[max];
nElems=0;
}
public void insert(long val){
a[nElems]=val;
nElems++;
}
/**
* 优化版冒泡排序
*/
public void bubbleSort(){
for(int out=0;out
a[in+1]){
swap(in, in+1);
}
}
}
}
/**
* 优化版冒泡排序
*/
public void bubbleSortPro(){
for(int out=nElems-1; out>0; out--){
for(int in=0;in
a[in+1]){
swap(in, in+1);
}
}
}
}
/**
* 冒泡+选择排序
*/
public void selectSort(){
for(int out=0;out
a[in]){
swap(out, in);
}
}
}
}
/**
* 选择排序-优化版
*/
public void selectSortPro(){
for(int out=0;out
a[in]){
min = in;
}
}
if(min!=out){
swap(out, min);
}
}
}
/**
* 插入排序
*/
public void insertSort(){
for(int i = 1;i < nElems; i ++){
if(a[i] < a[i-1]){
long temp = a[i];
int j;
for(j = i-1; j >= 0 && a[j] > temp; j --){
a[j+1] = a[j];
}
a[j+1] = temp;
}
}
}
public static void main(String[] args)
{
int maxSize = 100000;
ArraySort arr = new ArraySort(maxSize);
for(int j=0;j