Advertisement

Two Constant-Factor-Optimal Realizations of Adaptive Heapsort

  • Stefan Edelkamp
  • Amr Elmasry
  • Jyrki Katajainen
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7056)

Abstract

In this paper we introduce two efficient priority queues. For both, insert requires O(1) amortized time and extract-min \(O(\lg n)\) worst-case time including at most \(\lg n + O(1)\) element comparisons, where n is the number of elements stored. One priority queue is based on a weak heap (array-based) and the other on a weak queue (pointer-based). In both, the main idea is to temporarily store the inserted elements in a buffer, and once it is full to move its elements to the main queue using an efficient bulk-insertion procedure. By employing the new priority queues in adaptive heapsort, we guarantee, for several measures of disorder, that the formula expressing the number of element comparisons performed by the algorithm is optimal up to the constant factor of the high-order term. We denote such performance as constant-factor optimality. Unlike some previous constant-factor-optimal adaptive sorting algorithms, adaptive heapsort relying on the developed priority queues is practically workable.

Keywords

Priority queues weak heaps weak queues adaptive sorting adaptive heapsort constant-factor optimality 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Brodal, G.S., Fagerberg, R., Moruz, G.: Cache-Aware and Cache-Oblivious Adaptive Sorting. In: Caires, L., Italiano, G.F., Monteiro, L., Palamidessi, C., Yung, M. (eds.) ICALP 2005. LNCS, vol. 3580, pp. 576–588. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  2. 2.
    Brodal, G.S., Fagerberg, R., Moruz, G.: On the Adaptiveness of Quicksort. ACM J. Exp. Algorithmics 12, Article 3.2 (2008)Google Scholar
  3. 3.
    Carlsson, S., Levcopoulos, C., Petersson, O.: Sublinear Merging and Natural Mergesort. Algorithmica 9(6), 629–648 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Dutton, R.D.: Weak-heap Sort. BIT 33(3), 372–381 (1993)MathSciNetCrossRefGoogle Scholar
  5. 5.
    Edelkamp, S., Wegener, I.: On the Performance of Weak-Heapsort. In: Reichel, H., Tison, S. (eds.) STACS 2000. LNCS, vol. 1770, pp. 254–266. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  6. 6.
    Elmasry, A.: Priority Queues, Pairing and Adaptive Sorting. In: Widmayer, P., Triguero, F., Morales, R., Hennessy, M., Eidenbenz, S., Conejo, R. (eds.) ICALP 2002. LNCS, vol. 2380, pp. 183–194. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  7. 7.
    Elmasry, A.: Adaptive Sorting with AVL Trees. In: IFIP Int. Fed. Inf. Process., vol. 155, pp. 315–324. Springer, New York (2004)Google Scholar
  8. 8.
    Elmasry, A., Fredman, M.L.: Adaptive Sorting: An Information Theoretic Perspective. Acta. Inform. 45(1), 33–42 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Elmasry, A., Hammad, A.: Inversion-sensitive Sorting Algorithms in Practice. ACM J. Exp. Algorithmics 13, Article 1.11 (2009)Google Scholar
  10. 10.
    Elmasry, A., Jensen, C., Katajainen, J.: Multipartite Priority Queues. ACM Trans. Algorithms 5(1), Article 14 (2008)Google Scholar
  11. 11.
    Gabow, H.N., Bentley, J.L., Tarjan, R.E.: Scaling and Related Techniques for Geometry Problems. In: 16th Annual ACM Symposium on Theory of Computing, pp. 135–143. ACM, New York (1984)Google Scholar
  12. 12.
    Guibas, L.J., McCreight, E.M., Plass, M.F., Roberts, J.R.: A New Representation for Linear Lists. In: 9th Annual ACM Symposium on Theory of Computing, pp. 49–60. ACM, New York (1977)Google Scholar
  13. 13.
    Hoare, C.A.R.: Quicksort. Comput. J. 5(1), 10–16 (1962)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Knuth, D.E.: Sorting and Searching, The Art of Computer Programming, 2nd edn., vol. 3. Addison Wesley Longman, Reading (1998)zbMATHGoogle Scholar
  15. 15.
    Levcopoulos, C., Petersson, O.: Adaptive Heapsort. J. Algorithms 14(3), 395–413 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Levcopoulos, C., Petersson, O.: Splitsort: An Adaptive Sorting Algorithm. Inform. Process. Lett. 39(4), 205–211 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Levcopoulos, C., Petersson, O.: Exploiting Few Inversions When Sorting: Sequential and Parallel Algorithms. Theoret. Comput. Sci. 163(1-2), 211–238 (1996)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Mannila, H.: Measures of Presortedness and Optimal Sorting Algorithms. IEEE Trans. Comput. C-34(4), 318–325 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  19. 19.
    Mehlhorn, K.: Sorting Presorted Files. In: Weihrauch, K. (ed.) GI-TCS 1979. LNCS, vol. 67, pp. 199–212. Springer, Heidelberg (1979)Google Scholar
  20. 20.
    Moffat, A., Eddy, G., Petersson, O.: Splaysort: Fast, Versatile, Practical. Software Pract. Exper. 126(7), 781–797 (1996)CrossRefGoogle Scholar
  21. 21.
    Moffat, A., Petersson, O., Wormald, N.C.: A Tree-based Mergesort. Acta Inform. 35(9), 775–793 (1998)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Musser, D.R.: Introspective Sorting and Selection Algorithms. Software Pract. Exper. 27(8), 983–993 (1997)CrossRefGoogle Scholar
  23. 23.
    Saikkonen, R., Soisalon-Soininen, E.: Bulk-Insertion Sort: Towards Composite Measures of Presortedness. In: Vahrenhold, J. (ed.) SEA 2009. LNCS, vol. 5526, pp. 269–280. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  24. 24.
    Vuillemin, J.: A Data Structure for Manipulating Priority Queues. Commun. ACM 21(4), 309–315 (1978)MathSciNetCrossRefzbMATHGoogle Scholar
  25. 25.
    Vuillemin, J.: A Unifying Look at Data Structures. Commun. ACM 23(4), 229–239 (1980)MathSciNetCrossRefzbMATHGoogle Scholar
  26. 26.
    Williams, J.W.J.: Algorithm 232: Heapsort. Commun. ACM 7(6), 347–348 (1964)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Stefan Edelkamp
    • 1
  • Amr Elmasry
    • 2
  • Jyrki Katajainen
    • 2
  1. 1.TZIUniversität BremenGermany
  2. 2.Department of Computer ScienceUniversity of CopenhagenDenmark

Personalised recommendations