Selection Sort

Reference:

  1. Sorting algorithms/Selection sort


void SelectionSort(int *array, int n) 
{
    int i ,j ,m ,t;

    for(i = 0; i < n; i++) {
        for(j = i, m = i; j < n; j++) {
            if(array[j] < array[m])
                m = j;
        }

        t = array[i];
        array[i] = array[m];
        array[m] = t;
    }
}

results matching ""

    No results matching ""