Question: 3. Consider the following recursive algorithm: Preconditions: A is an array of integers. f and l are integers such that 0 s f (l- f

 3. Consider the following recursive algorithm: Preconditions: A is an array

3. Consider the following recursive algorithm: Preconditions: A is an array of integers. f and l are integers such that 0 s f (l- f +1)/2: 12 13 eturn maj(A, m1, ) return r (a) Let T(n) denote the worst-case running time of the algorithm below on inputs of size n. Write a recurrence relation satisfied by T. Then, give an asymptotic upper-bound for the worst-case running time of the algorithm Make sure to define n precisely and justify that your recurrence is correct by referring to the algorithm to describe how you obtained each term in your answer For this part of the question (and only this part), you may assume that len(Alf l 1]) and len(A) are powers of 2. (b) State an invariant for the loop on line 7 that describes the value of c at the end of every iteration of the loop Prove your loop in variant (c) Prove the correctness of maj with respect to the given specification. Use induction for the correctness proof and follow the steps (i)-(iv) below You may assume that the loop on line 7 terminates without proof. Also, you may use the following fact without proof: If u (l- f +1)/2: 12 13 eturn maj(A, m1, ) return r (a) Let T(n) denote the worst-case running time of the algorithm below on inputs of size n. Write a recurrence relation satisfied by T. Then, give an asymptotic upper-bound for the worst-case running time of the algorithm Make sure to define n precisely and justify that your recurrence is correct by referring to the algorithm to describe how you obtained each term in your answer For this part of the question (and only this part), you may assume that len(Alf l 1]) and len(A) are powers of 2. (b) State an invariant for the loop on line 7 that describes the value of c at the end of every iteration of the loop Prove your loop in variant (c) Prove the correctness of maj with respect to the given specification. Use induction for the correctness proof and follow the steps (i)-(iv) below You may assume that the loop on line 7 terminates without proof. Also, you may use the following fact without proof: If u

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!