Last active
August 29, 2015 14:17
-
-
Save carloszan/df8b2f36efaeab3b4166 to your computer and use it in GitHub Desktop.
Insertion Sort - C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T> | |
void insertion(T *data, int n) | |
{ | |
T temp; int j=0; | |
for(int i=1;i<n;i++) | |
{ | |
temp=data[i]; | |
for(j=i;j>0&&temp<data[j-1];j--) | |
data[j]=data[j-1]; | |
data[j]=temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment