Skip to content

Chance one bubble sort pass fully sorts 100 items

Question

A uniformly random permutation of 1,2,…,1001,2,\dots,100 goes through a single left-to-right pass of bubble sort. The probability that the list is then fully sorted can be written as abc!\dfrac{a^b}{c!} with integers a,b,ca,b,c. Find a+bca+bc.

Short answer

99029902. Running the pass backwards from the sorted list, each of the 9999 adjacent comparisons is either a swap or not, and each pattern yields a different starting permutation. So 2992^{99} of the 100!100! permutations work, and 2+99⋅100=99022+99\cdot100=9902.

Adapted from QuantQuestions.io; question and answer rewritten by SelfMadeQuant.com.

See the hint and the full worked solution in the question bank (free account).

Open the worked solution

Lessons behind this question

Start with a free lesson: Probability Fundamentals is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.

Read it free