Question: 3. Consider the following recursive algorithm: Preconditions: A is an array of integers. f and l are integers such that 0sfs& (e- f +1)/2: 12

 3. Consider the following recursive algorithm: Preconditions: A is an arrayof integers. f and l are integers such that 0sfs& (e- f

3. Consider the following recursive algorithm: Preconditions: A is an array of integers. f and l are integers such that 0sfs& (e- f +1)/2: 12 13.return maj(A, m 1,) i-i+1 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 : 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 invariant. (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 3. Consider the following recursive algorithm: Preconditions: A is an array of integers. f and l are integers such that 0sfs& (e- f +1)/2: 12 13.return maj(A, m 1,) i-i+1 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 : 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 invariant. (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

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!