# What is the expected number of apples that will be left in the basket? [duplicate]

Hi stumbled upon this interview question: There are 4 green and 50 red apples in a basket. They are removed one-by-one, without replacement, until all 4 green ones are extracted. What is the expected number of apples that will be left in the basket?

At first I thought it was 0, because there is always a chance for a green apple to be left in the basket, however since they are asking for the expected number of apples left, it actually makes sense that the number is positive. I found out that the answers is most likely 10, from various websites, however there is no solution anywhere. I have been trying to approach it with probabilities and with combination, however no luck so far. Some hints or a solution will be much appreciated.

• Do you have the individual probability that $m$ red apples are picked before the $4$ green apples? Then you can directly use the definition of the expectation value. Sep 6, 2016 at 10:35
• I see, unfortunately this is all the information I have. Sep 6, 2016 at 10:36
• Ok, so do you know how to calculate the above quantity, or should I include that in my answer? Sep 6, 2016 at 10:37
• Please include it in the answer. Thanks! Sep 6, 2016 at 10:38
• @GarethMcCaughan Indeed. Thanks, I was trying to find such a question. Sep 6, 2016 at 10:43

So we're looking for an average over all possible orders to pull the apples out in. (We'll include the ones after the last green one goes.) Here's one way to choose the order; I hope it's clear that it generates all orders with equal probability.

First, decide what order to take the green ones in.

Then, successively for each red apple, decide its position relative to the apples already placed.

Note that each red apple is then equally likely to lie in each of the five regions "before first green apple", "between first and second green apples", ..., "after fourth green apple".

This means that for a given red apple Pr(this apple is still there after the last green one is taken) = 1/5.

So the expected number of red apples left after the last green one is taken is $50\times\frac{1}{5}$ = 10.

• That's a very neat answer. Sep 6, 2016 at 10:45
• Thanks. (I worry that it may be difficult to grasp for someone who hasn't seen this kind of reasoning before, but I think the effort is worth it.) Sep 6, 2016 at 10:46
• It's worth it all right. I prefer an introduction via this argument rather than brute force. Sep 6, 2016 at 10:47
• I placed this formula in excel and verified it that it works with the 4 green 60 red apples as well. After that I drew what you said (easier for me to grasp) and I think it all makes sense. Interesting approach. Thank you! P.S. I put in my reasoning too as it may help someone else. Sep 6, 2016 at 10:53