| 11. | So, I echo the above and recommend an insertion sort for most human sorting needs.
|
| 12. | If you knew the array was almost sorted, wouldn't you simply insertion sort?
|
| 13. | Insertion sort is still recommended, though, for its situational performance and lack of recursion.
|
| 14. | Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list.
|
| 15. | Arguably, when you are not born a recursive thinker, insertion sort is easier than mergesort.
|
| 16. | So for unsorted input, insertion sort will usually perform about half as many comparisons as selection sort.
|
| 17. | If the input array is reverse-sorted, insertion sort performs as many comparisons as selection sort.
|
| 18. | Note that insertion sort produces the optimum result, i . e ., a correctly sorted list.
|
| 19. | For these reasons many modern algorithm textbooks avoid using the bubble sort algorithm in favor of insertion sort.
|
| 20. | As I do so, I perform an insertion sort ( I'd use a binary tree ).
|