Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 11, 2018 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save completejavascript/77bb42705b234ac1a0be7a08050ec302 to your computer and use it in GitHub Desktop.
Save completejavascript/77bb42705b234ac1a0be7a08050ec302 to your computer and use it in GitHub Desktop.
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