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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Cole, R.: On the dynamic finger conjecture for splay trees. Part II: The proof. SIAM J. Comput. 30, 44–85 (2000)
Dutton, R.: Weak-Heapsort. BIT 33, 372–381 (1993)
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)
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)
Estivill-Castro, V., Wood, D.: A survey of adaptive sorting algorithms. ACM Comput. Surv. 24(4), 441–476 (1992)
Floyd, R.: ACM algorithm 245: Treesort 3. Comm. of ACM 7(12), 701 (1964)
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)
Fredman, M., Sedgewick, R., Sleator, D., Tarjan, R.: The pairing heap: a new form of self adjusting heap. Algorithmica 1(1), 111–129 (1986)
Katajainen, J., Pasanen, T.: In-place sorting with fewer moves. Information Processing Letters 70(1), 31–37 (1999)
Katajainen, J., Pasanen, T., Teuhola, J.: Practical in-place Mergesort. Nordic Journal of Computing 3(1), 27–40 (1996)
Knuth, D.: The Art of Computer Programming, 2nd edn. Sorting and Searching, vol. III. Addison-Wesley, Reading (1998)
Levcopoulos, C., Petersson, O.: Adaptive Heapsort. J. of Alg. 14, 395–413 (1993)
Mannila, H.: Measures of presortedness and optimal sorting algorithms. IEEE Trans. Comput. C-34, 318–325 (1985)
McDiarmid, C., Reed, B.: Building heaps fast. J. of Alg. 10, 352–365 (1989)
Moffat, A., Eddy, G., Petersson, O.: Splaysort: fast, verstile, practical. Softw. Pract. and Exper. 126(7), 781–797 (1996)
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)
Roura, S.: Improving Mergesort for linked lists. In: Nešetřil, J. (ed.) ESA 1999. LNCS, vol. 1643, pp. 267–276. Springer, Heidelberg (1999)
Sleator, D., Tarjan, R.: Self-adjusting binary search trees. J. ACM 32(3), 652–686 (1985)
Tarjan, R.: Amortized computational complexity. SIAM J. Alg. Disc. Meth. 6, 306–318 (1985)
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)
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)
Williams, J.: ACM algorithm 232: Heapsort. Comm. of ACM 7(6), 347–348 (1964)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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