-
from http://www.concentric.net/~ttwang/sort/sort.htm
- Exchange two adjacent elements if they are out of order. Repeat untilarray is sorted. This is a slow algorithm.
- Find the largest element in the array, and put it in the proper place.Repeat until array is sorted. This is also slow.
- Scan successive elements for out of order item, then insert the itemin the proper place. Sort small array fast, big array very slowly.
- Partition array into two segments. The first segment all elements areless than or equal to the pivot value. The second segment all elements aregreater or equal to the pivot value. Sort the two segments recursively.Quicksort is fastest on average, but sometimes unbalanced partitions canlead to very slow sorting.
- Start from two sorted runs of length 1, merge into a single run of twicethe length. Repeat until a single sorted run is left. Mergesort needsN/2 extra buffer. Performance is second place on average, withquite good speed on nearly sorted array. Mergesort is stable in thattwo elements that are equally ranked in the array will not have their relativepositions flipped.
- Form a tree with parent of the tree being larger than its children.Remove the parent from the tree successively. On average, Heapsort isthird place in speed. Heapsort does not need extra buffer, and performanceis not sensitive to initial distributions.
- Sort every Nth element in an array using insertion sort. Repeat usingsmaller N values, until N = 1. On average, Shellsort is fourth place inspeed. Shellsort may sort some distributions slowly.
- Sorting algorithms can be mixed and matched to yield the desiredproperties. We want fast average performance, good worst case performance,and no large extra storage requirement. We can achieve the goal by startingwith the Quicksort (fastest on average). We modify Quicksort by sortingsmall partitions by using Insertion Sort (best with small partition). Ifwe detect two partitions are badly balanced, we sort the larger partitionby Heapsort (good worst case performance). Of course we cannot undo thebad partitions, but we can stop the possible degenerate case from continuingto generate bad partitions.
![*](http://www.concentric.net/%7Ettwang/icons/pinkbal.gif)
![*](http://www.concentric.net/%7Ettwang/icons/pinkbal.gif)
![*](http://www.concentric.net/%7Ettwang/icons/pinkbal.gif)
![*](http://www.concentric.net/%7Ettwang/icons/pinkbal.gif)
![*](http://www.concentric.net/%7Ettwang/icons/pinkbal.gif)
![*](http://www.concentric.net/%7Ettwang/icons/pinkbal.gif)
![*](http://www.concentric.net/%7Ettwang/icons/pinkbal.gif)