We have to find Total Pairs in all permutation.
n distinct numbers
Number of Pairs, $N =\binom{n}{2} = \frac{n(n-1)}{2}$ (can be considered as size of the upper triangle of a square matrix)
event A: Inversion for a pair.
Probability ( Inversion for a pair) = $P = P(A) = \frac{1}{2}$ (either there is inversion or there is not)
Similarly, $q = \frac{1}{2}$
Random Variable X: Number of Inversions
$X\sim B (N=\binom{n}{2}, P=\frac{1}{2})$
$E(X) = \mu = NP$
$= \binom{n}{2} . \frac{1}{2} = \frac{n(n-1)}{4}$
Complexity = $\theta (n^2)$
Similar Question – https://gateoverflow.in/949/gate2003-61