Class | Sorting algorithm |
---|---|
Data structure | Array |
Worst-case performance | comparisons and swaps |
Best-case performance | comparisons, swaps |
Average performance | comparisons and swaps |
Worst-case space complexity | total, auxiliary |
Optimal | No |
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time by comparisons. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. However, insertion sort provides several advantages:
When people manually sort cards in a bridge hand, most use a method that is similar to insertion sort.[2]
pearls
was invoked but never defined (see the help page).