Skip to main content

Three Sorting Algorithms Using Priority Queues

  • Conference paper
Algorithms and Computation (ISAAC 2003)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2906))

Included in the following conference series:

Abstract

We establish a lower bound of B(n) = n⌈logn ⌉ − 2⌈logn + 1 on the number of comparisons performed by any algorithm that uses priority queues to sort n elements. Three sorting algorithms using priority queues are introduced. The first algorithm performs the same comparisons as the classical Mergesort algorithm, but in a different order. The second algorithm performs at most 2nlogn + O(n) comparisons, with the advantage of being adaptive; meaning that it runs faster when the input sequence has some presortedness. In particular, we show that this algorithm sorts an already sorted sequence in linear time; a fact that is not obvious since there is no special checks to guarantee this behavior. The third algorithm is almost implicit; it can be implemented using the input array and less than n extra bits. The number of comparisons performed by this algorithm is at most B(n)+2.5n. The three algorithms have the advantage of producing every element of the sorted output, after the first, in O(log n), and can be implemented to be practically efficient.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Cole, R.: On the dynamic finger conjecture for splay trees. Part II: The proof. SIAM J. Comput. 30, 44–85 (2000)

    Article  MATH  MathSciNet  Google Scholar 

  2. Dutton, R.: Weak-Heapsort. BIT 33, 372–381 (1993)

    Article  MathSciNet  Google Scholar 

  3. Edelkamp, S., Wegener, I.: On the performance of weak-heapsort. In: Reichel, H., Tison, S. (eds.) STACS 2000. LNCS, vol. 1770, pp. 254–260. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  4. 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)

    Chapter  Google Scholar 

  5. Estivill-Castro, V., Wood, D.: A survey of adaptive sorting algorithms. ACM Comput. Surv. 24(4), 441–476 (1992)

    Article  Google Scholar 

  6. Floyd, R.: ACM algorithm 245: Treesort 3. Comm. of ACM 7(12), 701 (1964)

    Article  Google Scholar 

  7. Fredman, M.: A priority queue transform. In: Vitter, J.S., Zaroliagis, C.D. (eds.) WAE 1999. LNCS, vol. 1668, pp. 243–257. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  8. Fredman, M., Sedgewick, R., Sleator, D., Tarjan, R.: The pairing heap: a new form of self adjusting heap. Algorithmica 1(1), 111–129 (1986)

    Article  MATH  MathSciNet  Google Scholar 

  9. Katajainen, J., Pasanen, T.: In-place sorting with fewer moves. Information Processing Letters 70(1), 31–37 (1999)

    Article  MATH  MathSciNet  Google Scholar 

  10. Katajainen, J., Pasanen, T., Teuhola, J.: Practical in-place Mergesort. Nordic Journal of Computing 3(1), 27–40 (1996)

    MathSciNet  Google Scholar 

  11. Knuth, D.: The Art of Computer Programming, 2nd edn. Sorting and Searching, vol. III. Addison-Wesley, Reading (1998)

    Google Scholar 

  12. Levcopoulos, C., Petersson, O.: Adaptive Heapsort. J. of Alg. 14, 395–413 (1993)

    Article  MATH  MathSciNet  Google Scholar 

  13. Mannila, H.: Measures of presortedness and optimal sorting algorithms. IEEE Trans. Comput. C-34, 318–325 (1985)

    Article  MathSciNet  Google Scholar 

  14. McDiarmid, C., Reed, B.: Building heaps fast. J. of Alg. 10, 352–365 (1989)

    Article  MATH  MathSciNet  Google Scholar 

  15. Moffat, A., Eddy, G., Petersson, O.: Splaysort: fast, verstile, practical. Softw. Pract. and Exper. 126(7), 781–797 (1996)

    Article  Google Scholar 

  16. Reinhardt, K.: Sorting in-place with a worst case complexity of n log n – 1.3n + O(log n) comparisons and εn log n+ O(1) transports. In: Ibaraki, T., Iwama, K., Yamashita, M., Inagaki, Y., Nishizeki, T. (eds.) ISAAC 1992. LNCS, vol. 650, pp. 489–499. Springer, Heidelberg (1992)

    Google Scholar 

  17. Roura, S.: Improving Mergesort for linked lists. In: Nešetřil, J. (ed.) ESA 1999. LNCS, vol. 1643, pp. 267–276. Springer, Heidelberg (1999)

    Google Scholar 

  18. Sleator, D., Tarjan, R.: Self-adjusting binary search trees. J. ACM 32(3), 652–686 (1985)

    Article  MATH  MathSciNet  Google Scholar 

  19. Tarjan, R.: Amortized computational complexity. SIAM J. Alg. Disc. Meth. 6, 306–318 (1985)

    Article  MATH  MathSciNet  Google Scholar 

  20. Wegener, I.: The worst case complexity of McDiarmid and Reed’s variant of Bottomup Heapsort is less than n log n+1. 1n. Inform. and Comput. 97(1), 86–96 (1992)

    Article  MATH  MathSciNet  Google Scholar 

  21. Wegener, I.: Bottom-up-Heapsort, a new variant of Heapsort, beating on an average, Quicksort (if n is not very small). Theor. Comp. science 118, 81–98 (1993)

    Article  MATH  MathSciNet  Google Scholar 

  22. Williams, J.: ACM algorithm 232: Heapsort. Comm. of ACM 7(6), 347–348 (1964)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2003 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Elmasry, A. (2003). Three Sorting Algorithms Using Priority Queues. In: Ibaraki, T., Katoh, N., Ono, H. (eds) Algorithms and Computation. ISAAC 2003. Lecture Notes in Computer Science, vol 2906. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-24587-2_23

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-24587-2_23

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-20695-8

  • Online ISBN: 978-3-540-24587-2

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics