Several other sorts have similar asymptotic profiles to
insertion sort, with different advantages and disadvantages.
insertion sort: To sort , recursively sort
. Then, bubble A[n] downward until it stops.
T(n) = n + T(n-1). Worst case , best case on sorted list.
selection sort: To sort , pick out the max in
. Move max to the end in one swap. Recurse on . T(n) = n + T(n-1). Running time is always .Swaps , which is asymptotically optimal.
Bubble sort: Scan through the list over and over again swapping
adjacent elements that are out of order. Like insertion sort only
much slower.