While insertion sort is widely used because it is so simple, it is possible to obtain much more efficient algorithms (when sorting large numbers of elements) by paying the price of a little extra complexity in algorithm design. For example, quicksort sorts by partitioning a sequence into two halves, sorting each half, and then combining the halves to produce a sorted sequence. The partitioning rearranges the sequence elements so that all elements to the left are less than or equal to all the elements to the right. The payoff is that the sorted subsequences can be merged by just concatenating them. Theoretically, partitioning around the median is necessary to achieve optimal performance (to balance sizes of the subproblems), but in practice an approximation to the median is good enough. Though quicksort has a potentially O(n2) performance, the average case performance is O(n log n). Hence it is the perferred sorting algorithm for large data sets in most cases.
KeywordsComposition Operator Recursive Call Recursive Partition Symbolic Execution Partition Algorithm
Unable to display preview. Download preview PDF.