Annals of Combinatorics

, Volume 12, Issue 4, pp 417–447 | Cite as

Sorting Using Complete Subintervals and the Maximum Number of Runs in a Randomly Evolving Sequence

  • Svante JansonEmail author


We study the space requirements of a sorting algorithm where only items that at the end will be adjacent are kept together. This is equivalent to the following combinatorial problem: Consider a string of fixed length n that starts as a string of 0’s, and then evolves by changing each 0 to 1, with the n changes done in random order. What is the maximal number of runs of 1’s? We give asymptotic results for the distribution and mean. It turns out that, as in many problems involving a maximum, the maximum is asymptotically normal, with fluctuations of order n 1/2, and to the first order well approximated by the number of runs at the instance when the expectation is maximized, in this case when half the elements have changed to 1; there is also a second order term of order n 1/3. We also treat some variations, including priority queues and sock-sorting. The proofs use methods originally developed for random graphs.


sorting algorithm runs priority queues sock-sorting evolution of random strings Brownian motion 

AMS Subject Classification

60C05 68W40 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    af Hällström G.: Ein lineares Inselproblem der kombinatorischen Wahr-schein-lich-keitsrech- nung, Ann. Acad. Sci. Fennicae. Ser. A. I. Math.-Phys. 1952(123), 9 (1952)MathSciNetGoogle Scholar
  2. 2.
    Barbour A.D.: A note on the maximum size of a closed epidemic. J. R. Stat. Soc. Ser. B 37(3), 459–460 (1975)zbMATHMathSciNetGoogle Scholar
  3. 3.
    Barbour A.D.: Brownian motion and a sharply curved boundary. Adv. in Appl. Probab. 13(4), 736–750 (1981)zbMATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Billingsley P.: Convergence of Probability Measures. John Wiley & Sons, New York- London-Sydney (1968)zbMATHGoogle Scholar
  5. 5.
    Daniels H.E.: The maximum size of a closed epidemic. Adv. in Appl. Probab. 6, 607–621 (1974)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Daniels H.E.: The maximum of a Gaussian process whose mean path has a maximum, with an application to the strength of bundles of fibres. Adv. in Appl. Probab. 21(2), 315–333 (1989)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Daniels H.E., Skyrme T.H.R.: The maximum of a random walk whose mean path has a maximum. Adv. in Appl. Probab. 17(1), 85–99 (1985)zbMATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Flajolet P., Françon J., Vuillemin J.: Sequence of operations analysis for dynamic data structures. J. Algorithms 1(2), 111–141 (1980)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Flajolet P., Puech C., Vuillemin J.: The analysis of simple list structures. Inform. Sci. 38(2), 121–146 (1986)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Groeneboom P.: Brownian motion with a parabolic drift and Airy functions. Probab. Theory Related Fields 81(1), 79–109 (1989)CrossRefMathSciNetGoogle Scholar
  11. 11.
    Gut A.: Probability: A Graduate Course. Springer, New York (2005)zbMATHGoogle Scholar
  12. 12.
    Jacod J., Shiryaev A.N.: Limit Theorems for Stochastic Processes. Springer-Verlag, Berlin (1987)zbMATHGoogle Scholar
  13. 13.
    Janson S.: A functional limit theorem for random graphs with applications to subgraph count statistics. Random Structures Algorithms 1(1), 15–37 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Janson S.: Orthogonal decompositions and dunctional limit theorems for random graph statistics. Mem. Amer. Math. Soc. 111(534), vi+78 (1994)MathSciNetGoogle Scholar
  15. 15.
    Janson S.: Functional limit theorems for multitype branching processes and generalized P´olya urns. Stochastic Process. Appl. 110(2), 177–245 (2004)CrossRefMathSciNetGoogle Scholar
  16. 16.
    Kallenberg O.: Foundations of Modern Probability, 2nd Ed. New York, Springer-Verlag (2002)zbMATHGoogle Scholar
  17. 17.
    Kenyon C.M., Vitter J.S.: Maximum queue size and hashing with lazy deletion. Algorithmica 6(4), 597–619 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  18. 18.
    W.V. Li and G. Pritchard, A central limit theorem for the sock-sorting problem, In: High Dimensional Probability, Progr. Probab., Vol. 43, Birkhäuser, Basel, (1998) pp. 245–248.Google Scholar
  19. 19.
    Louchard G.: Random walks, Gaussian processes and list structures, Theoret. Comput. Sci. 53(1), 99–124 (1987)zbMATHMathSciNetGoogle Scholar
  20. 20.
    Louchard G.: Large finite population queueing systems part I: the infinite server model. Comm. Statist. Stochastic Models 4(3), 473–505 (1988)zbMATHCrossRefMathSciNetGoogle Scholar
  21. 21.
    Louchard G., Kenyon C., Schott R.: Data structures’ maxima. SIAM J. Comput. 26(4), 1006–1042 (1997)zbMATHCrossRefMathSciNetGoogle Scholar
  22. 22.
    Mood A.M.: The distribution theory of runs. Ann. Math. Statistics 11, 367–392 (1940)zbMATHCrossRefMathSciNetGoogle Scholar
  23. 23.
    D. Steinsaltz, Random time changes for sock-sorting and other stochastic process limit theorems, Electron. J. Probab. 4 (1999) paper 14.Google Scholar
  24. 24.
    Stevens W.L.: Distribution of groups in a sequence of alternatives. Annals of Eugenics 9, 10–17 (1939)MathSciNetGoogle Scholar
  25. 25.
    Van Wyk C.J., Vitter J.S.: The complexity of hashing with lazy deletion. Algorithmica 1, 17–29 (1986)zbMATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Birkhäuser Verlag Basel/Switzerland 2009

Authors and Affiliations

  1. 1.Department of MathematicsUppsala UniversityUppsalaSweden

Personalised recommendations