Maths Olympiad Prep

Library / /1369 of 1394

, 2018

Combinatorics Difficulty 6.3 National Olympiad Prove it United States

Problem:
A tourist is learning an incorrect way to sort a permutation (p1,,pn)\left(p_{1}, \ldots, p_{n}\right) of the integers (1,,n)(1, \ldots, n). We define a fix on two adjacent elements pip_{i} and pi+1p_{i+1}, to be an operation which swaps the two elements if pi>pi+1p_{i}>p_{i+1}, and does nothing otherwise. The tourist performs n1n-1 rounds of fixes, numbered a=1,2,,n1a=1,2, \ldots, n-1. In round aa of fixes, the tourist fixes pap_{a} and pa+1p_{a+1}, then pa+1p_{a+1} and pa+2p_{a+2}, and so on, up to pn1p_{n-1} and pnp_{n}. In this process, there are (n1)+(n2)++1=n(n1)2(n-1)+(n-2)+\cdots+1=\frac{n(n-1)}{2} total fixes performed. How many permutations of (1,,2018)(1, \ldots, 2018) can the tourist start with to obtain (1,,2018)(1, \ldots, 2018) after performing these steps?

Solution

Solution:
Note that the given algorithm is very similar to the well-known Bubble Sort algorithm for sorting an array. The exception is that in the ii-th round through the array, the first i1i-1 pairs are not checked.

We claim a necessary and sufficient condition for the array to be sorted after the tourist's process is: for all ii, after ii rounds, the numbers 1,,i1, \cdots, i are in the correct position. Firstly, this is necessary because these indices of the array are not touched in future rounds - so if a number was incorrect, then it would stay incorrect. On the other hand, suppose this condition holds. Then, we can "add" the additional fixes during each round (of the first i1i-1 pairs during the ii-th round) to make the process identical to bubble sort. The tourist's final result won't change because by our assumption these swaps won't do anything. However, this process is now identical to bubble sort, so the resulting array will be sorted. Thus, our condition is sufficient.

Now, there are two positions the 11 can be in (p1,p2)\left(p_{1}, p_{2}\right). There are three positions the 22 can be in (p1,,p4)\left(p_{1}, \cdots, p_{4}\right) except for the position of 11. Similarly, for 1i10091 \leq i \leq 1009 there are 2i(i1)=i+12i-(i-1)=i+1 positions ii can be in, and after that the remaining 10091009 numbers can be arranged arbitrarily. Thus, the answer is 1010!1009!1010! \cdot 1009!.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.