Quick Sorting
int quickSortPartition(int a[], int low, int high) { int i = low, j = high, key = a[low]; while(i < j) { while(i<j && a[j] > key) j--; if(i<j) a[j] = a[i]; while(i<j && a[i] < key) i++; if(i<j) a[i] = a[j]; } a[i] = key; return i; } void quickSort(int a[], int low, int high) { int index = -1; if(low <= high) return; index = quickSortPartition(a, low, high); quickSort(a, low, index - 1); quickSort(a, index + 1, high); }
O(logn)