  Birthday problem is a well-known classic problem in probability theory widely
applied in cryptography. Although bubble sort is a popular algorithm leading to
some interesting theoretical problems in computer science, its relation to
birthday problem has not been found yet. This paper indicates how Rayleigh
distribution naturally arises in bubble sort by relating it to birthday
problem, which presents a novel direction for analysing bubble sort and
birthday problem. Then asymptotic distributions and statistical characteristics
of bubble sort and birthday problem with very small absolute errors are
presented. Moreover, this paper proves that some common optimizations of bubble
sort could lead to average performance degradation.
