complexity is O(n2)
performance adapts to the initial order of elements
insertion sort is used on quite small data sets
properties:
- stable : insertion sort retains relative order of the same elements
- in place
http://www.algolist.net/Algorithms/Sorting/Insertion_sort
complexity is O(n2)
n + (n - 1) + (n - 2) + ... + 1, results in O(n2) number of comparisons. Number of swaps may vary from zero (in case of sorted array) to n - 1 (in case array was sorted in reversed order), which results in O(n) number of swaps. Overall algorithm complexity is O(n2).