Search for question
Question

What is the big-O runtime for the routine, measured as a function of its return value i?

If the numbers are chosen independently at random, then the probability that firstDecrease(L) returns i is

(i-1)/i!, except for the special case of i=n+1 for which the probability is 1/n! Use this fact to write an

expression for the expected value returned by the algorithm. (Your answer can be expressed as a sum, it does

not have to be solved in closed form. Do not use O-notation.)

What is the big-O average case running time of the routine? Hint: Simplify the previous summation until

you see a common taylor series.