English

Relating bubble sort to birthday problem

Probability 2024-09-24 v2

Abstract

Birthday problem is a well-known classic problem in probability theory widely applied in cryptography, and bubble sort is a popular sorting algorithm leading to some interesting theoretical problems in computer science. However, the relation between bubble sort and birthday problem has not been discovered. By relating bubble sort to birthday problem, based on a generalization of Poisson limit theorem for dissociated random variables, this paper offers an intuitive explanation to naturally indicate that nPnn\displaystyle \frac{n - P_{n}}{\sqrt{n}} converges in distribution to the standard Rayleigh distribution, where PnP_{n} is the number of passes required to bubble sort nn distinct elements. Then asymptotic distributions and statistical characteristics of bubble sort and birthday problem are presented. Moreover, this paper discovers that some common optimizations of bubble sort could lead to average performance degradation.

Cite

@article{arxiv.2404.11170,
  title  = {Relating bubble sort to birthday problem},
  author = {Jichu Jiang},
  journal= {arXiv preprint arXiv:2404.11170},
  year   = {2024}
}

Comments

14 pages

R2 v1 2026-06-28T15:56:53.773Z