I need help to solve a problem related to bucket sort algorithm, where we have n numbers of input and n buckets. Example that I got from the book shows a problem where the probability of an item falls into a certain bucket is equal = .
Now, I find a problem in which we have n buckets and we generate n numbers (range 0 - 1) randomly. If the generated number y is >0.5, we toss a coin. If the coin turns up 'HEAD', then y=y-0.5.
The questions are:
Thanks.
With probability 1 / 2, y is greater than 1/2; conditioned on this, the probability that it falls into the first bucket is (1 / 2) (2 / n).
By the total probability theorem, the probability is 1.5 / n. By symmetry, this is true for each of the first half of buckets.
Since the probability is 1.5 / n for each of the first half of buckets, the probability for each of the last half is, by symmetry, (1 - (n / 2)(1.5 / n)) / (0.5n) = 0.5 / n.
The expectation is linear. By linearity of expectation, the expectation is the sum of the expectations of the times to (quadratically) sort each of the buckets. Each of the first and half buckets has constant expected time. The proof is essentially the same as for classic bucket sort: the distribution per bucket is Bernoulli with parameter α / n for some α.