0
$\begingroup$

Say you have a list of $N$ numbers, and each run you randomly select one from them. If it is what your wanted, then you stop and record the number of runs $n$, else you run another iteration until you got it.

What is the expected number of runs, i.e. $E[n]$, for this? I guess it would not change if you have a sorted list or not?

  • 0
    Is selection done with replacement, or without?2017-01-29
  • 0
    with replacement2017-01-29

1 Answers 1

3

Probability that it'll take $n$ runs to see your desired number for the first time is $$(1-p)^{n-1} p,$$ were $p = \frac{1}{N}$. This is a random variable with geometric distribution and its expected value is $\frac{1}{p} = N$.

For more information about geometric distribution see here.