Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

2. How will the team select a leader?

Answered: 1 week ago

Question

3. What may be the goal of the team?

Answered: 1 week ago