1.时间复杂度
2.快排
public class QuickSortTest {
public static void main(String[] args) {
int[] a = {2, 34, 56, 7, 9, 12, 33};
quickSort(a, 0, a.length - 1);
for (int i = 0; i < a.length; i++) {
System.out.println(a[i]);
}
}
public static void quickSort(int[] a, int left, int right) {
int i = left;
int j = right;
if (i >= j) return;
int temp = a[left];
while (i < j) {
while (i < j && temp >= a[i]) {
i++;
}
while (i < j && temp <= a[j]) {
j--;
}
if (i < j) {
int m = a[i];
a[i] = a[j];
a[j] = m;
}
}
a[left] = a[i];
a[i] = temp;
quickSort(a, left, i - 1);
quickSort(a, i + 1, right);
}
}