Skip to content
Related Articles
Open in App
Not now

Related Articles

GATE | GATE-CS-2003 | Question 61

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

In a permutation a1… of n distinct integers, an inversion is a pair (ai, aj) such that i aj. If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of 1…..n ?
(A) n(n – 1)/2

(B) n(n – 1)/4
(C) n(n + 1)/4
(D) 2n[log2 n]

Answer: (B)


There are n(n-1)/2 pairs such that i < j.

For a pair (ai, aj), probability of being inversion is 1/2.

Therefore expected value of inversions = 1/2 * (n(n-1)/2)
                                       = n(n-1)/4

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!