Sorting shuffled monotone sequences

  • Christos Levcopoulos
  • Ola Petersson
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 447)


We present a new sorting algorithm which adapts to existing order within the input sequence. Let k be the smallest integer such that a sequence X of length n can be reduced to the empty sequence by the removal of k monotone, increasing or decreasing, subsequences. The algorithm, Slabsort, sorts X in O(n log k) time, without knowing k beforehand, which is optimal in a comparison-based model. In the worst case Slabsort degenerates to a hybrid of Melsort and Exact Quicksort and runs in Θ(n log n) time. Further, k is shown to capture various kinds of existing order proposed in the literature.

Key words

sorting algorithm presortedness measures shuffled sequences optimality 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    A.V. Aho, J.E. Hopcroft, and J.D. Ullman. Data Structures and Algorithms. Addison-Wesley, Reading, Mass., 1983.Google Scholar
  2. [2]
    A. Brandstädt and D. Kratsch. On partitions of permutations into increasing and decreasing subsequences. Journal of Information Processing and Cybernetics, 22(5/6):263–273, 1986.Google Scholar
  3. [3]
    S. Carlsson, C. Levcopoulos, and O. Petersson. Sublinear merging and Natural Merge Sort. In Proc. SIGAL International Symposium on Algorithms. LNCS, Springer-Verlag, 1990. To appear.Google Scholar
  4. [4]
    C.R. Cook and D.J. Kim. Best sorting algorithms for nearly sorted lists. Communications of the ACM, 23(11):620–624, 1980.CrossRefGoogle Scholar
  5. [5]
    G.R. Dromey. Exploiting partial order with Quicksort. Software—Practice and Experience, 14(6):509–518, 1984.Google Scholar
  6. [6]
    V. Estivill-Castro, H. Mannila, and D. Wood. Right invariant metrics and measures of presortedness. Research Report CS-89-30, University of Waterloo, Department of Computer Science, Waterloo, Canada, 1989.Google Scholar
  7. [7]
    V. Estivill-Castro and D. Wood. A new measure of presortedness. Information and Computation, 83(1):111–119, 1989.CrossRefGoogle Scholar
  8. [8]
    M.L. Fredman. On computing the length of longest increasing subsequences. Discrete Mathematics, 11:29–35, 1975.Google Scholar
  9. [9]
    D.E. Knuth. The Art of Computer Programming, Vol. 3: Sorting and Searching. Addison-Wesley, Reading, Mass., 1973.Google Scholar
  10. [10]
    C. Levcopoulos and O. Petersson. Heapsort—adapted for presorted files. In Proc. 1989 Workshop on Algorithms and Data tructures, pages 499–509. LNCS 382, Springer-Verlag, 1989.Google Scholar
  11. [11]
    C. Levcopoulos and O. Petersson. Splitsort—an adaptive sorting algorithm. In Proc. Fifteenth Symposium on Mathematical Foundations of Computer Science. LNCS, Springer-Verlag, 1990. To appear.Google Scholar
  12. [12]
    H. Mannila. Measures of presortedness and optimal sorting algorithms. IEEE Transactions on Computers, C-34(4):318–325, 1985.Google Scholar
  13. [13]
    K. Mehlhorn. Sorting presorted files. In Proc. 4th GI Conference on Theoretical Computer Science, pages 199–212. LNCS 67, Springer-Verlag, 1979.Google Scholar
  14. [14]
    K. Mehlhorn. Data Structures and Algorithms, Vol 1: Sorting and Searching. Springer-Verlag, Berlin/Heidelberg, F.R. Germany, 1984.Google Scholar
  15. [15]
    C. Schensted. Longest increasing and decreasing subsequences. Canadian Journal of Mathematics, 13:179–191, 1961.Google Scholar
  16. [16]
    S.S. Skiena. Encroaching lists as a measure of presortedness. BIT, 28(4):775–784, 1988.MathSciNetGoogle Scholar
  17. [17]
    K. Wagner. Monotonic coverings of finite sets. Journal of Information Processing and Cybernetics, 20(12):633–639, 1984.Google Scholar
  18. [18]
    R.L. Wainwright. A class of sorting algorithms based on Quicksort. Communications of the ACM, 28(4):396–402, 1985.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1990

Authors and Affiliations

  • Christos Levcopoulos
    • 1
  • Ola Petersson
    • 1
  1. 1.Algorithm Theory Group, Department of Computer ScienceLund UniversityLundSweden

Personalised recommendations