Skip to content

Instantly share code, notes, and snippets.

@anshumanatri
Created March 12, 2009 10:10
Show Gist options
  • Save anshumanatri/77988 to your computer and use it in GitHub Desktop.
Save anshumanatri/77988 to your computer and use it in GitHub Desktop.
void quicksort(int l, int u)
{ int i, m;
if (l >= u) return;
swap(l, randint(l, u));
m = l;
for (i = l+1; i <= u; i++)
if (x[i] < x[l])
swap(++m, i);
swap(l, m);
quicksort(l, m-1);
quicksort(m+1, u);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment