Skip to content

Instantly share code, notes, and snippets.

@ramsundarg
Last active August 18, 2018 17:41
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 ramsundarg/2ca3b3e83ac6879183360a028b2ae95c to your computer and use it in GitHub Desktop.
Save ramsundarg/2ca3b3e83ac6879183360a028b2ae95c to your computer and use it in GitHub Desktop.
void quicksort(int start,int end, int a[])
{
pivot = start;
lp = start+1;
rp = end;
if(start == end)
return;
while(lp<rp)
{
while(a[lp]>a[pivot])
lp++;
while(a[rp]<a[pivot])
rp--;
swap(a[rp],a[lp]);
}
swap(a[pivot],a[lp]);
quicksort(pivot+1,lp,a);
quicksort(lp+1,end,a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment