Sorting multisets stably in minimum space

AbstractWe consider the problem of sorting a multiset of sizen containingm distinct elements, where theith distinct element appearsni times. Under the assumption that our model of computation allows only the operations of comparing elements and moving elements in the memory,Ω(n logn − ∑i=1mni logni +n) is known to be a lower bound for the computational complexity of the sorting problem. In this paper we present aminimum space algorithm that sortsstably a multiset in asymptoticallyOptimal worst-case time. A Quicksort type approach is used, where at each recursive step the median is chosen as the partitioning element. To obtain a stable minimum space implementation, we develop linear-time in-place algorithms for the following problems, which have interest of their own: Stable unpartitioning: Assume that ann-element arrayA is stably partitioned into two subarraysA0 andA1. The problem is to recoverA from its constitutentsA0 andA1. The information available is the partitioning element used and a bit array of sizen indicating whether an element ofA0 orA1 was originally in the corresponding position ofA. Stable selection: The task is to find thekth smallest element in a multiset ofn elements such that the relative order of identical elements is retained.

[1]  Donald E. Knuth,et al.  The art of computer programming: sorting and searching (volume 3) , 1973 .

[2]  Manuel Blum,et al.  Time Bounds for Selection , 1973, J. Comput. Syst. Sci..

[3]  Edward C. Horvath,et al.  Stable Sorting in Asymptotically Optimal Time and Extra Space , 1978, JACM.

[4]  Teofilo F. Gonzalez,et al.  Sorting Numbers in Linear Expected Time and Optimal Extra Space , 1982, Inf. Process. Lett..

[5]  Michael A. Langston,et al.  Fast Stable Merging and Sorting in Constant Extra Space , 1992, Comput. J..

[6]  J. Ian Munro,et al.  Sorting and Searching in Multisets , 1976, SIAM J. Comput..

[7]  Jeffrey S. Salowe,et al.  Stable Unmerging in Linear Time and Constant Space , 1987, Inf. Process. Lett..

[8]  Donald E. Knuth,et al.  The Art of Computer Programming, Vol. 3: Sorting and Searching , 1974 .

[9]  Michael A. Langston,et al.  Practical in-place merging , 1987, CACM.

[10]  Christos Levcopoulos,et al.  Sorting Shuffled Monotone Sequences , 1994, Inf. Comput..

[11]  Jyrki Katajainen,et al.  Stable minimum space partitioning in linear time , 1992, BIT.

[12]  Michael A. Langston,et al.  Stable duplicate-key extraction with optimal time and space bounds , 2004, Acta Informatica.

[13]  Christos Levcopoulos,et al.  An Optimal Adaptive In-place Sorting Algorithm , 1991, FCT.

[14]  Ellis Horowitz,et al.  Fundamentals of Computer Algorithms , 1978 .

[15]  Branislav Durian Quicksort Without a Stack , 1986, MFCS.

[16]  Venkatesh Raman,et al.  Sorting Multisets and Vectors In-Place , 1991, WADS.

[17]  J. IAN MUNRO,et al.  An Implicit Data Structure Supporting Insertion, Deletion, and Search in O(log² n) Time , 1986, J. Comput. Syst. Sci..

[18]  Lutz M. Wegner A generalized, one-way, stackless quicksort , 1987, BIT Comput. Sci. Sect..

[19]  Derick Wood,et al.  Implicit Selection , 1988, SWAT.

[20]  Robert Sedgewick Quicksort with Equal Keys , 1977, SIAM J. Comput..

[21]  Alistair Moffat,et al.  An Overview of Adaptive Sorting , 1992, Aust. Comput. J..

[22]  Venkatesh Raman,et al.  Stable in situ sorting and minimum data movement , 1990, BIT.

[23]  Jeffrey S. Salowe,et al.  Simplified Stable Merging Tasks , 1987, J. Algorithms.

[24]  J. Ian Munro,et al.  An Implicit Binomial Queue with Constant Insertion Time , 1988, SWAT.

[25]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[26]  Christos Levcopoulos,et al.  Space-Efficient Parallel Merging , 1992, PARLE.