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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!