Skip to content

Instantly share code, notes, and snippets.

@jermenkoo
Created November 25, 2014 15:36
Show Gist options
  • Save jermenkoo/0db29af73c0d11673508 to your computer and use it in GitHub Desktop.
Save jermenkoo/0db29af73c0d11673508 to your computer and use it in GitHub Desktop.
public static void quickSort(int start, int end, int[] a) {
int pivot = (a[start] + a[end]) / 2;
int left = start;
int right = end;
int temp;
//pivotization
while (left <= right) {
while (a[left] < pivot) left++;
while (a[right] > pivot) right--;
if (left <= right) {
temp = a[left];
a[left] = a[right];
a[right] = temp;
left++;
right--;
}
}
if (start < right) quickSort(start, right, a);
if (left < end) quickSort(left, end, a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment