Q3 B

Sameh avatar
Sameh
c_cpp
01/09/2024 6:49 PM
376 B
16
Indexable
void insertionSort(int *a , int n)
{
    int temp , j;
    for (int i = 1 ; i < n ; i++)
    {
        temp = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > a[i])
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j+1] = temp;
    }
}
Editor is loading...
Leave a Comment