Amazon Interview Question
Software Engineer / Developersthe bin has a max capacity of 50.putting 25 w 25 b in each bin will give a prob of 1/4 (1/2 * 1/2) for the event which is the max achievable. what do u think ?
Let x be the number of white beads in 1 bin. The other bin has (50-x).
Probability of choosing white bead in first bin = x/50 * 1/2 (probability of choosing 1st bin).
Probability of choosing white bead in second bin = (50-x)/50 * 1/2
Probability of choosing a white bead in any bin = sum of the two. = 1/2.
if you think about it mathematically it's 50% what ever you do... however I did not see them set any constrains on the box or how you put them in... lets say I have a 5x5 (marble) box that can be tightly packed. I put the 25 blacks on the bottom. and rest of the whites on top if you draw from the top it's always white... you can take this to with a 50x1x1 box too i guess just like a stack.
The first answer cannot be right as the question specifically says that there must be 50 beads in each bin. Statistically there is no way then to maximise your chances of choosing any particular colour - as shown by XYZ, knap and G. In practice however, there would be several ways such as placing white beads on top (mentioned) and putting all the white beads in the bin on the right for right-handers. Of course, if the clause to put exactly 50 beads in each bin falls away, then the first answer is very good.
Actually, JC is exactly right. While there will always be 50 beads, the first thing that is done statistically, is choosing a bin, a 1/2 chance. The second event is the number of beads in the selected jar. So, if you put 1 white bead in the first bin, that gives you a 100& chance of picking white IF that bin is selected (a 1/2 chance).
Putting all of the remaining beads in the second bin ensures a virtual 50/50 chance of picking white. Therefore, IF that bin is selected, the odds are 1/2 that its white. this leaves you with the following chance:
Bin 1: 100% chance of picking white * 1/2 chance of bin 1 being chosen = 50%
Bin 2: 50% chance f picking white * 1/2 chance of bin 2 being chosen - 25%
Add the two together, and you have a 75% chance of choosing a white bead in this scenario.
Statistically, We've maximized our chances.
How about this? Putting all 50 white beads in one bin, all 50 black beads in the other bin. Then choose one bead out of any bin if the bead is white, then you know the bin contains only white, so you can choose only white beads. If the first chosen bead is black, then we choose the other bin and also you can choose only white beans...
- Anonymous January 08, 2009