My first encounter on my journey to re-learn algorithm is the insertion sort algorithm. This the code that I took from TADM book:
insertion_sort(item s[], int n)
{
int i,j; /* counters */
for (i=1; i<n; i++) {
j=i;
while ((j>0) && (s[j] < s[j-1])) {
swap(&s[j],&s[j-1]);
j = j-1;
}
}
}
And this is the illustration that I took from the net:

Insertion Sort
From the code and the illustration, you can see the characteristics of insertion sort are:
1. Start from index 1. Why? Because if the list length is 1 then there is no point to sort it.
2. There are 2 loops. One for iterating the list and the other for comparing the current index with the item on the behind. The second loop only keeps iterating if the current item is lower than the item behind.
3. Swapping. When comparing backward, the lower item will be swapped with the higher item. So this swapping needs an array to be fast.