Skip to content

Instantly share code, notes, and snippets.

@jsam
Last active February 2, 2018 10:34
Show Gist options
  • Save jsam/7386369 to your computer and use it in GitHub Desktop.
Save jsam/7386369 to your computer and use it in GitHub Desktop.
quicksort
void quickSort(zaposlenici arr*, int left, int right)
{
int i = left, j = right;
zaposlenici tmp;
zaposlenici *pivot = arr[(left + right) / 2];
/* partition */
while (i <= j) {
while (arr[i]->oib < pivot->oib)
i++;
while (arr[j]->oib > pivot->oib)
j--;
if (i <= j) {
tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i++;
j--;
}
}
/* recursion */
if (left < j)
quickSort(arr, left, j);
if (i < right)
quickSort(arr, i, right);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment