Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

bubble sort

int *BubbleSort(int ar[], int size)
{
    bool sorted = false;
    while (sorted == false)
    {
        sorted = true;
        for (int i = 0; i < size; i++)
        {
            if (ar[i] > ar[i + 1])
            {
                swap(ar[i], ar[i + 1]);
                sorted = false;
            }
        }
    }
    return ar;
}
Source by favtutor.com #
 
PREVIOUS NEXT
Tagged: #bubble #sort
ADD COMMENT
Topic
Name
2+3 =