quickSort
#1

This function:

Code:
stock quickSort(array[], left=0, right)
{
    new
        tempLeft = left,
        tempRight = right,
        pivot = array[(left + right) / 2],
        tempVar
    ;
    while(tempLeft <= tempRight)
    {
        while(array[tempLeft] < pivot) tempLeft++;
        while(array[tempRight] > pivot) tempRight--;

        if(tempLeft <= tempRight)
        {
            tempVar = array[tempLeft], array[tempLeft] = array[tempRight], array[tempRight] = tempVar;
            tempLeft++, tempRight--;
        }
    }
    if(left < tempRight) quickSort(array, left, tempRight);
    if(tempLeft < right) quickSort(array, tempLeft, right);
}
Can sort float numbers?
Reply


Messages In This Thread
quickSort - by MerryDeer - 29.08.2016, 11:44
Re: quickSort - by Kaliber - 29.08.2016, 12:58
Re: quickSort - by Gammix - 29.08.2016, 23:22
Re: quickSort - by MerryDeer - 30.08.2016, 07:46

Forum Jump:


Users browsing this thread: 1 Guest(s)