Also, could you send me a pseudo code to explain algorithm:
public class QuickSorter //method call to do the sort
{
public static void quickSort(int[ ] array){
quickSort(array, 0, array.length);
}
private static void quickSort(int[ ] array, int first, int last) { // main method
if (first < last) {
int pivot = pivotList(array, first, last); //
quickSort(array, first, pivot - 1);
quickSort(array, pivot + 1, last);
}
}
//* @param a an array of Comparable items.
private static int pivotList(int[ ] array, int first, int last) { //take in the list
int pivotValue = array[first]; // assign first element of array
int pivotPoint = first; //
for (int index = first + 1; index < last; index++) { // recursive
2007-12-13
04:34:11
·
1 answers
·
asked by
sprite
3
in
Computers & Internet
➔ Programming & Design
if (array[index] < pivotValue) {
pivotPoint = pivotPoint + 1;
int temp = array[pivotPoint];// assign array temp
array[pivotPoint] = array[index];
array[index] = temp;
}
}
int temp = array[first]; // sort by rearange
array[first] = array[pivotPoint];
array[pivotPoint] = temp;
return pivotPoint;
}
}
2007-12-13
04:34:29 ·
update #1