Created
September 11, 2018 19:26
-
-
Save completejavascript/77bb42705b234ac1a0be7a08050ec302 to your computer and use it in GitHub Desktop.
This file contains 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
void QuickSort(int *a, int left, int right) | |
{ | |
int l = left, r = right; | |
int pivot = a[(l + r) / 2]; | |
while(l <= r) | |
{ | |
while(a[l] < pivot) l++; | |
while(a[r] > pivot) r--; | |
if(l <= r) | |
{ | |
swap(a[l], a[r]); | |
l++; | |
r--; | |
} | |
} | |
if(left < r) | |
Quick(a, left, r); | |
if(l < right) | |
Quick(a, l, right); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment