Heapsort—Adapted for presorted files

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


We provide a new sorting algorithm which is optimal with respect to several known, and new, measures of presortedness. A new such measure, called Osc(X), measures the oscillation within the input data. The measure has an interesting application in the sweep-line technique in computational geometry. Our algorithm is based on a new approach which yields space efficiency and it uses simple data structures. For example, after a linear time preprocessing step, the only data structures used are a static tree and a heap.

Key words

sorting algorithm measures presortedness heap geometric interpretation optimality 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [CK80]
    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
  2. [Ede87]
    H. Edelsbrunner. Algorithms in Combinatorial Geometry. Springer-Verlag, Berlin/Heidelberg, F.R. Germany, 1987.Google Scholar
  3. [EW87]
    V. Estivill-Castro and D. Wood. A new measure of presortedness. Research Report CS-87-58, University of Waterloo, Department of Computer Science, Waterloo, Canada, 1987.Google Scholar
  4. [GMPR77]
    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
  5. [Man84]
    H Mannila. Implementation of a sorting algorithm suitable for presorted files. Technical Report, Department of Computer Science, University of Helsinki, Finland, 1984.Google Scholar
  6. [Man85]
    H. Mannila. Measures of presortedness and optimal sorting algorithms. IEEE Transactions on Computers, C-34(4):318–325, 1985.Google Scholar
  7. [Meh79]
    K. Mehlhorn. Sorting presorted files. In Proc. 4th GI Conference on Theoretical Computer Science, pages 199–212, Springer-Verlag, 1979.Google Scholar
  8. [Meh84a]
    K. Mehlhorn. Data Structures and Algorithms, Vol 1: Sorting and Searching. Springer-Verlag, Berlin/Heidelberg, F.R. Germany, 1984.Google Scholar
  9. [Meh84b]
    K. Mehlhorn. Data Structures and Algorithms, Vol. 3: Multidimensional Searching and Computational Geometry. Springer-Verlag, Berlin/Heidelberg, F.R. Germany, 1984.Google Scholar
  10. [ORo87]
    J. O'Rourke. Art Gallery Theorems and Algorithms. Oxford University Press, New York/Oxford, 1987.Google Scholar
  11. [PS85]
    F.P. Preparata and M.I. Shamos. Computational Geometry: An Introduction. Springer-Verlag, New York, N.Y., 1985.Google Scholar
  12. [Ski88]
    S.S. Skiena. Encroaching lists as a measure of presortedness. BIT, 28:775–784, 1988.MathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1989

Authors and Affiliations

  • Christos Levcopoulos
    • 1
  • Ola Petersson
    • 1
  1. 1.Department of Computer and Information ScienceLinköping UniversityLinköpingSweden

Personalised recommendations