Sorting multisets and vectors in-place
When a list to be sorted consists of many repeated elements (i.e. when it is a multiset), the familiar Ω(n lg n) lower bound on the number of comparisons is replaced by a bound that depends on the multiplicities of the elements in the list. We adapt heapsort for multisets and provide the first in-place algorithm for multisets that achieves the optimal bound up to lower order terms. We, then, obtain an optimal in-place algorithm to lexicographically sort an array of multidimensional vectors, by applying the multiset sorting algorithm in each coordinate.
We exploit the relationship between the two sorting problems to improve the lower order term of a known lower bound for sorting multisets. It follows that the (“non in-place”) algorithms developed by Munro and Spira  for multisets are within O(n) time optimal. Our improvement to the lower bound for sorting multisets also improves a lower bound (in the lower order term) for determining the mode, the most frequently occurring element in the multiset.
KeywordsData Movement Repeated Element Lower Order Term Output Buffer Suffix Array
Unable to display preview. Download preview PDF.
- J. L. Bently and J. B. Saxe, Algorithms on Vector Sets, SIGACT News, Fall (1979) 36–39.Google Scholar
- D. Dobkin and J. I. Munro, Determining the Mode, Theoretical Computer Science 12 (1980) 255–263.Google Scholar
- Th. M. Fischer, Refined Bounds on the Complexity of Sorting and Selection in D-Dimensional Space, Proceedings of MFCS, Lecture Notes in Computer Science, Springer Verlag 233 (1986) 309–314.Google Scholar
- G. H. Gonnet and J. I. Munro, Heaps on Heaps, SIAM Journal of Computing 15 (4) (1986), 964–971.Google Scholar
- D. E. Knuth, The Art of Computer Programming. Volume I: Fundamental Algorithms, Addison-Wesley (1973).Google Scholar
- D. E. Knuth, The Art of Computer Programming. Volume III: Sorting and Searching, Addison-Wesley (1973).Google Scholar
- U. Manber and G. Myers, Suffix Arrays: A New Method for On-Line String Searches, Proceedings of the first annual ACM-SIAM Symposium on Discrete Algorithms (1990) 319–327.Google Scholar
- I. Munro and P. M. Spira, Sorting and Searching in Multisets, SIAM Journal of Computing, 5 (1) (1976) 1–8.Google Scholar
- L. M. Wegner, Quicksort for Equal Keys, IEEE Transactions on Computers, C-34 (4) (1985) 362–367.Google Scholar
- J. Wiedermann, The Complexity of Lexicographic Sorting and Searching, Proceedings of MFCS, Lecture Notes in Computer Science, Springer Verlag 74 (1979) 517–522.Google Scholar