Created
November 25, 2014 15:36
-
-
Save jermenkoo/0db29af73c0d11673508 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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