Question: 5. Provide a tight bound on the the worst case runtime for the following algorithms (recall that n = 0 is not the worst case

 5. Provide a tight bound on the the worst case runtime

5. Provide a tight bound on the the worst case runtime for the following algorithms (recall that n = 0 is not the worst case scenario!). Be sure to clearly indicate: (i) what the worst case scenario is (ii) T(n) in the worst case (iii) tight bound on the worst case runtime complexity Use as reference for what is expected of a solution the example in the file cramples.pdf attached with Lecture 9 slides. Correct answers without proper justification will get zero points. (a) (8 points) Assume that sorting an array with p elements takes (plog(P)) time. Require: Matrix X = (X.)man, I real numbers, Vi, j 1: if m n then 2: for i = 1,...,n do 3: sort column (3.) in ascending order 4: end for 5: else 6: for i = 1,...,m do 7: for j = 1,..., n do 8: 1 = 26-i) 9: end for 10: end for 11: end if (b) (8 points) The following algorithm was provided above, but reproduced below for convenience. Analyze the algorithm exactly as indicated, even if you corrected it in the previous question. Require: >0.n> 1: ans = 1, a = x, p=n 2: while p > 0 do 3: if p is odd then ans = ans * a aasa p= (p-1)/2 else a=a*a 9: p=p/2 10: end if 11: end while 12: return ans

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!