希尔排序大概三秒,这个运行了很长时间没出结果
public static void main(String[] args) {
//int[] arr = {-9, 78, 0, 23, -567};
int[] arr = new int[8000000];
for (int i = 0; i < 8000000; i++) {
arr[i] = (int)(Math.random() * 800000);
}
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
String format = simpleDateFormat.format(date);
System.out.println(format);
quick_Sort(arr, 0, arr.length - 1);
Date date1 = new Date();
String format1 = simpleDateFormat.format(date1);
System.out.println(format1);
//System.out.println(Arrays.toString(arr));
}
public static void quick_Sort(int[] arr, int low, int high) {
int i = low;
int temp;
if (low < high) {
int pivot = arr[high];
for (int j = low; j < high; j++) {
if (arr[j] < pivot) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
}
}
arr[high] = arr[i];
arr[i] = pivot;
quick_Sort(arr, 0, i - 1);
quick_Sort(arr, i + 1, high);
}
}