As an exercise, I've written quicksort algorithm in C using pointers. Please comment and help me find the cases where it breaks (if any).
void qsort(int *, int, int);
void swap(int *, int *);
void qsort(int *v, int left, int right)
{
int i, *last;
if (right <= left)
return;
last = v + left; //choosing the first element as the pivot
for (i = left + 1; i <= right; i++)
if (*(v + i) < *(v + left))
swap(++last, v + i); //swapping the numbers < pivot
swap(v + left, last);
qsort(v, left, last - v - 1); //sub-array containing numbers < pivot
qsort(v, last - v + 1, right); //sub-array containing numbers >= pivot
}
void swap(int *i, int *j)
{
int temp;
temp = *i;
*i = *j;
*j = temp;
}