Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 1)/i!, except for the special case of i - n+1 for which the probability is 1! 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.) 5c) What is the big-O average case running time of the routine? Hint: Simplify the previous summation until you see a common taylor series
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started