Hey guys. I have another question regarding IRV. I did several of them between this question and the last I posted, but this one is confusing to me.

Here's the question:

Let A[1 ... n] be an array of n distinct numbers.

If i < j and A[i] > A[j], then the pair (i,j) is called an inversion of A.

Suppose that each element of A is chosen uniformly at random from the range 1 through n.

Use indicator random variables to compute the expected number of inversions.

Ok, so I did some trial and error and I think the maximum number of inversions (I understand the whole inversion explanation) is 2n. I didn't try it to very high numbers though... So I'm not entirely confident on that.

Now, do I want to set up my

to be 0 ... 2n ?

Then how do I calculated the expected value of

, would it be

to be

reducing to

? I'm trying to do this by... Possibility * Probability.

But now I think I may have mixed this whole thing up so any help is really appreciated. We only had the one lecture ("crash course") on this, so I'm a bit overwhelmed, honestly. Thank you!