Selman ALPDÜNDAR

Generic Insertion Sort in C/C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
template <class T>
void Insertion (T *Array, int size){
    T temp;
    int i;
    for(int j=1; j<size; j++){
        temp=Array[j];
        i=j-1;
        while(i>=0 && Array[i]>temp){
            Array[i+1]=Array[i];
            i=i-1;
        }
        Array[i+1]=temp;
    }
}


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.