GATE / CS ARCHIVE

GATE CSE 2003 / QUESTION 61

Expected inversion count in a uniform permutation

Discrete Mathematics · Probability & Random Variables · Full GATE CSE 2003 paper

GATE 2003, Q61 2 marks · MCQ
Report issue

Probability & Random Variables

Question 61, GATE 2003: For a permutation a1,...,an of n distinct integers, an inversion is an index pair i<j with ai>aj. All permutations of 1,...,n are equally likely. What is the expected inversion count?
A. n(n−1)/2
B. n(n−1)/4
C. n(n+1)/4
D. 2n floor(log2 n)
Question 61, GATE 2003: For a permutation a1,...,an of n distinct integers, an inversion is an index pair i<j with ai>aj. All permutations of 1,...,n are equally likely. What is the expected inversion count?
A. n(n−1)/2
B. n(n−1)/4
C. n(n+1)/4
D. 2n floor(log2 n)
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. There are choose(n,2)=n(n−1)/2 pairs of distinct positions i<j.
2. For any fixed pair, exchanging their two entries pairs every ordering ai>aj with an equally likely ordering ai<aj. Distinctness excludes equality, so the inversion probability is 1/2.
3. Let Iij be 1 for an inversion and 0 otherwise. Then E[Iij]=1/2 and total inversions I=Σi<j Iij.
4. Linearity gives E[I]=Σ E[Iij]=n(n−1)/4, B. Although different pairs' indicators may be dependent, linearity does not require independence.

Solution: For each of the n(n−1)/2 index pairs i<j, define an indicator for aᵢ>aⱼ. Symmetry gives probability 1/2 for each pair. By linearity of expectation, the expected inversion count is [n(n−1)/2]×1/2=n(n−1)/4, option B. Independence among those indicators is unnecessary.

Original paper, page 9