Home > Algorithms > Given n red balls and m blue balls and some containers, how would you distribute those balls among the containers such that the probability of picking a red ball is maximized, assuming that the user randomly chooses a container and then randomly picks a ball from that

Given n red balls and m blue balls and some containers, how would you distribute those balls among the containers such that the probability of picking a red ball is maximized, assuming that the user randomly chooses a container and then randomly picks a ball from that

July 7, 2012

Given n red balls and m blue balls and some containers, how would you distribute those balls among the containers such that the probability of picking a red ball is maximized, assuming that the user randomly chooses a container and then randomly picks a ball from that

Solutiuon :

Let’s say x containers.

Put 1 red ball in x-1 containers and rest with m blue balls.

Probability of selecting red ball in this case is: 1-(1/x)*(n-x-1)/m.

Advertisements
Categories: Algorithms
%d bloggers like this: