Your job is to pick one ball from a collection of balls in such a way that
every ball has an equal probability of being selected. The twist is that
you do not know how many balls are in the collection. Each ball will be
handed to you, one at a time. As each ball is handed to you you must decide
(by some random process) whether to keep or discard the ball.
You must always be holding one and only one ball so that when a new ball is
given to you, you must either discard it or keep it by discarding the
previously held ball.
(In reply to re(3): Very Simple
Shuffle a deck of n cards including the ace of spades; choose a card at random and if it's the ace of spades, take the new ball in preference to the one you already have. After 52, add cards from another deck, but don't use the ace of spades from any decks but the first.
Posted by Charlie
on 2004-10-22 19:09:22