Splitsort—an adaptive sorting algorithm
- 767 Downloads
We present a new sorting algorithm, called Splitsort which adapts to existing order within the input sequence. The algorithm is optimal with respect to several known measures of presortedness, including the number of inversions, for which no such simple and space efficient algorithm was known before. The amount of extra space needed is only n + O(log n) pointers. Splitsort uses a simple data structure and is easy to code. In the worst case Splitsort performs 2.5 n log2n comparisons, but if the input is presorted according to some of the measures it completes the sorting task considerably faster. We also show how a variant of the algorithm can be implemented to run in-place.
KeywordsSorting Algorithm Sorting Task Extra Space Unordered Pair Input Array
Unable to display preview. Download preview PDF.
- S. Carlsson, C. Levcopoulos, and O. Petersson. Sublinear merging and Natural Merge Sort. In Proc. SIGAL Int. Symp. on Algorithms. LNCS, Springer-Verlag, 1990. To appear.Google Scholar
- C.R. Cook and D.J. Kim. Best sorting algorithms for nearly sorted lists. Communications of the ACM, 23(11):620–624, 1980.Google Scholar
- V. Estivill-Castro and D. Wood. A new measure of presortedness. Information and Computation, 83(1):111–119, 1989.Google Scholar
- L.J. Guibas, E.M. McCreight, M.F. Plass, and J.R. Roberts. A new representation of linear lists. In Proc. 9th Annual ACM Symposium on Theory of Computing, pages 49–60, 1977.Google Scholar
- B-C. Huang and M.A. Langston. Practical in-place merging. CACM, 31(3):348–352, 1988.Google Scholar
- C. Levcopoulos and O. Petersson. Heapsort—adapted for presorted files. In Proc. 1989 WADS, pages 499–509. LNCS 382, Springer-Verlag, 1989.Google Scholar
- C. Levcopoulos and O. Petersson. Sorting shuffled monotone sequences. In Proc. 2nd SWAT. LNCS, Springer-Verlag, 1990. To appear.Google Scholar
- H. Mannila. Measures of presortedness and optimal sorting algorithms. IEEE Transactions on Computers, C-34(4):318–325, 1985.Google Scholar
- K. Mehlhorn. Data Structures and Algorithms, Vol 1: Sorting and Searching. 1984.Google Scholar
- S.S. Skiena. Encroaching lists as a measure of presortedness. BIT, 28(4):775–784, 1988.Google Scholar
- R.L. Wainwright. A class of sorting algorithms based on Quicksort. CACM, 28(4):396–402, 1985.Google Scholar