Sorting multisets and vectors in-place

  • J. Ian Munro
  • Venkatesh Raman
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 519)


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[2] for sorting multisets. It follows that the (“non in-place”) algorithms developed by Munro and Spira [8] 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.


Data Movement Repeated Element Lower Order Term Output Buffer Suffix Array 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    J. L. Bently and J. B. Saxe, Algorithms on Vector Sets, SIGACT News, Fall (1979) 36–39.Google Scholar
  2. [2]
    D. Dobkin and J. I. Munro, Determining the Mode, Theoretical Computer Science 12 (1980) 255–263.Google Scholar
  3. [3]
    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
  4. [4]
    G. H. Gonnet and J. I. Munro, Heaps on Heaps, SIAM Journal of Computing 15 (4) (1986), 964–971.Google Scholar
  5. [5]
    D. E. Knuth, The Art of Computer Programming. Volume I: Fundamental Algorithms, Addison-Wesley (1973).Google Scholar
  6. [6]
    D. E. Knuth, The Art of Computer Programming. Volume III: Sorting and Searching, Addison-Wesley (1973).Google Scholar
  7. [7]
    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
  8. [8]
    I. Munro and P. M. Spira, Sorting and Searching in Multisets, SIAM Journal of Computing, 5 (1) (1976) 1–8.Google Scholar
  9. [9]
    L. M. Wegner, Quicksort for Equal Keys, IEEE Transactions on Computers, C-34 (4) (1985) 362–367.Google Scholar
  10. [10]
    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

Copyright information

© Springer-Verlag Berlin Heidelberg 1991

Authors and Affiliations

  • J. Ian Munro
    • 1
  • Venkatesh Raman
    • 1
  1. 1.Department of Computer ScienceUniversity of WaterlooCanada

Personalised recommendations