Practical Algorithms for Generating a Random Ordering of the Elements of a Weighted Set

  • Kevin J. Lang
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7288)


This paper discusses the problem of efficiently generating a random ordering of the elements of an n-element weighted set, where the elements’ weights are interpreted as relative probabilities. The paper reviews the current status of this problem, which includes a purely theoretical algorithm with the optimal O(n) cost, then presents several new algorithms that are simple, practical and nearly optimal, including one with an expected cost of O(n loglogn) on worst-case inputs, and another one with an expected cost of O(n) when the weights are randomly chosen from distributions that are believed to be ubiquitous in the real world. It is still an open question whether there exists a practical algorithm with O(n) expected cost on worst case inputs.


Random Permutation Expected Cost Practical Algorithm Balance Tree Discrete Probability Distribution 
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.
    Bayer, D., Diaconis, P.: Trailing the dovetail shuffle to its lair. The Annals of Applied Probability 2(2), 294–313 (1992)MathSciNetzbMATHCrossRefGoogle Scholar
  2. 2.
    Cover, T.M., Thomas, J.A.: Elements of information theory, 2nd edn. Wiley (2006)Google Scholar
  3. 3.
    Knuth, D.E.: The Art of Computer Programming. Seminumerical Algorithms, 2nd edn., vol. II. Addison-Wesley (1981)Google Scholar
  4. 4.
    Knuth, D.E.: The art of computer programming. Sorting and Searching, 2nd edn., vol. 3. Addison Wesley Longman Publishing Co., Inc., Redwood City (1998)Google Scholar
  5. 5.
    Matias, Y., Vitter, J.S., Ni, W.-C.: Dynamic generation of discrete random variates. Theory Comput. Syst. 36(4), 329–358 (2003)MathSciNetzbMATHCrossRefGoogle Scholar
  6. 6.
    Newman, M.E.J.: Power laws, pareto distributions and zipf’s law. Contemporary Physics 46, 323–351 (2005)CrossRefGoogle Scholar
  7. 7.
    Walker, A.J.: An efficient method for generating discrete random variables with general distributions. ACM Transactions on Mathematical Software 3(3), 253–256 (1977)zbMATHCrossRefGoogle Scholar
  8. 8.
    Wong, C.K., Easton, M.C.: An efficient method for weighted sampling without replacement. SIAM J. Comput. 9(1), 111–113 (1980)MathSciNetzbMATHCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Kevin J. Lang
    • 1
  1. 1.Yahoo! ResearchUSA

Personalised recommendations