Question: 5. (3 points) The following routine takes as input a list of n numbers, and returns the first value of i for which L[i ]

5. (3 points) The following routine takes as input a list of n numbers, and returns the first value of i for which L[i ] = L[i-1]; i++) { } return i 5a) What is the big-O runtime for the routine, measured as a function of its return value i? 5b) If the numbers are chosen independently at random, then the probability that firstDecrease(L) returns i is (i I/it, except for the special case of i -n+ for which the probability is I/m! 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.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
