0
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ 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. $\endgroup$ Sep 6, 2016 at 10:35
  • $\begingroup$ I see, unfortunately this is all the information I have. $\endgroup$
    – Newskooler
    Sep 6, 2016 at 10:36
  • $\begingroup$ Ok, so do you know how to calculate the above quantity, or should I include that in my answer? $\endgroup$ Sep 6, 2016 at 10:37
  • $\begingroup$ Please include it in the answer. Thanks! $\endgroup$
    – Newskooler
    Sep 6, 2016 at 10:38
  • $\begingroup$ @GarethMcCaughan Indeed. Thanks, I was trying to find such a question. $\endgroup$
    – Newskooler
    Sep 6, 2016 at 10:43

1 Answer 1

5
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ That's a very neat answer. $\endgroup$ Sep 6, 2016 at 10:45
  • 1
    $\begingroup$ 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.) $\endgroup$ Sep 6, 2016 at 10:46
  • 1
    $\begingroup$ It's worth it all right. I prefer an introduction via this argument rather than brute force. $\endgroup$ Sep 6, 2016 at 10:47
  • $\begingroup$ 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. $\endgroup$
    – Newskooler
    Sep 6, 2016 at 10:53

Not the answer you're looking for? Browse other questions tagged .