Insertion sort
Insertion sort
The algorithm consists of iterations. At iterations , we sort the prefix of array of length . That is, before iteration , the subarray is sorted, and after the -th iteration, the subarray will be sorted. To do this, it is enough to find the right place to put .