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

2,688

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.

Share:
2,688
Author by

### Newskooler

I love to ski and snowmobile. When off the mountain, I enjoy spending time surfing and bjj. All questions, answers, comments and code are from me personally, and in no way represent the opinions of my employer.

Updated on September 07, 2020

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.

• Sarvesh Ravichandran Iyer about 7 years
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.
I see, unfortunately this is all the information I have.
• Sarvesh Ravichandran Iyer about 7 years
Ok, so do you know how to calculate the above quantity, or should I include that in my answer?