a) without replacement:

let?s think about the possible values |X-Y| can take. It can be 0 if there are the same number of reds in the first two as in the last two such as RGR. Or it can be 1 if there is 1 more red in the first two, such as RRG, or 1 more red in the last two, such as GRR. There are no other values it can take. By the definition of expected value: E(|X-Y|) = 0 * P(|X-Y| = 0) + 1 * P(|X-Y| = 1) Which simplifies to simply P(|X-Y| = 1). This is the same as what is the probability that the green ball is selected first or the green ball is selected last?

The probability the green ball is selected first is 1/3, and by symmetry, the probability that the green ball is selected last is also 1/3. These two events are mutually exclusive, so the probability that the first ball is green or the last ball is green is 1/3 + 1/3 = **2/3**.

b) With replacement:

What has changed? Well, now there are a couple more sequences which weren?t possible before. Like now you can get RRR or GGG or GRG, but in those cases, the number of red balls in the first two balls and the number of red balls in the last two balls are the same, so |X-Y| would equal 0. You can now get GGR or RGG, which would result in |X-Y| = 1. This time, what you draw doesn?t effect what you draw next (the draws are independent).

The probability of getting the sequence RRG is 2/3*2/3*1/3 = 4/27.

The probability of getting GRR is 1/3*2/3*2/3 = 4/27.

The probability of getting GGR is 1/3*1/3*2/3 = 2/27.

The probability of getting RGG is 2/3*1/3*1/3 = 2/27.

So the probability that |X-Y| = 1, and thus, the expected value of |X-Y| = 4/27 + 4/27 + 2/27 + 2/27 = **4/9**.