In sorting networks, a comparator of positions $i < j$ is an operator which takes a permutation, checks if $p_i > p_j$, and if it is the case, swaps $p_i$ and $p_j$.
Using this, we can define the following procedure:
- Uniformly choose a permutation $p$ of $1, 2, ..., n$
- Until $p$ is sorted (i.e. it's the identity permutation):
- Uniformly choose two indices, $i < j$, and apply the comparator $i, j$ to $p$.
There are two random variables which interest us: $X$, the number of iterations of the loop until the permutation is sorted, and $Y$, the number of swaps performed. In particular, we are interested in their expected value.
Simulating this procedure many times for multiple values of $n$ seems to suggest that $\mathbf{E}[X] = \Theta(n^2 \log(n))$, while $\mathbf{E}[Y] = \omega(n \log(n))$, and perhaps $\mathbf{E}[Y] = \Theta(n \log(n) \log(\log(n)))$, although it's more vague.
Is this correct? If it is, is there a nice value to $\lim_{n\to \infty} \frac{\mathbf{E}[X]}{n^2 \log(n)}$ and $\lim_{n\to \infty} \frac{\mathbf{E}[Y]}{n \log(n) \log(\log(n))}$? If not, what are the correct asymptotic expressions?
EDIT: I believe can prove that $\mathbf{E}[X] = O(n^3)$ for any distribution of permutations, since the time to sort a permutation of size $n$ is at most the time to bring $n$ to the $n$-th place (from which it can't be displaced), which is expected $\binom{n}2$, plus the time to sort the rest of the permutation. So we get $\binom{n}{2} + \binom{n-1}{2} + \cdots = \Theta(n^3)$. However, this still seems much more than the actual value.