struct Cell
{
int data;
int occur;
};
void quickSort(struct Cell* space, int pos_pivot, int pos_end)
{
if(pos_pivot < pos_end)
{
int pos_div = partition(space, pos_pivot, pos_end);
quickSort(space, pos_pivot, pos_div);
quickSort(space, pos_div + 1, pos_end);
}
return;
}
int partition(struct Cell* space, int pos_pivot, int pos_end)
{
int i, j, x;
if(pos_pivot < pos_end)
{
x = space[pos_pivot].data;
i = pos_pivot - 1;
j = pos_end + 1;
while(1)
{
do
{
i++;
}while( i < SIZE && space[i].data < x);
do
{
j--;
}while( j >= 0 && space[j].data > x);
if(i >= j)
{
break;
}
else
swap(&space[i], &space[j]);
}
return j;
}
return -1;
}