Archive for June 2nd, 2008
The codes might be not optimized, and the first elements of all arrays are chosen as the pivots, which will cause a tremendous slow-down when the array is sorted already.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public static void swap(int[] ar, int a, int b){
int tmp = ar[a];
ar[a] = ar[b];
ar[b] = tmp;
}
public static int partition(int[] a, int left, int right) {
int pivot=a[left];
int [...]
Categories: Programming
Tags: Array, Arrays, Elements, Int Tmp, java, Java Codes, Partition, Pivots, Programming, Public Static Void, quicksort, Quicksort Java
