C&S 2024 Exam - Question 3 (b)

 avatar
itsLu
c_cpp
a month ago
336 B
1
Indexable
Never
#include <iostream>
using namespace std;

void Insertion_Sort (int arr[], int n)
{
    int key, k, m;
    for (k = 0 ; k < n ; k++)
    {
        key = arr[k];
        m = k - 1;
        while (m >= 0 && arr[m] > key)
        {
            arr[m + 1] = arr[m];
            m--;
        }
        arr[m+1] = key;
    }
}
Leave a Comment