Question: Question 5: Consider the following recursive algorithm. Assume that n is a power of 3 , that is, n=3k for an integer k. The subroutine,

 Question 5: Consider the following recursive algorithm. Assume that n is

Question 5: Consider the following recursive algorithm. Assume that n is a power of 3 , that is, n=3k for an integer k. The subroutine, Thirds, takes list A as input and arranges the elements such that the smallest n/3 items in A are in locations 0..3n1 and the largest n/3 items in A are in locations 32n..n1. Thirds requires 2n significant operations to do this. (a) Prove that Algorithm Magicsort correctly sorts the elements in the array A. (b) Write the recurrence in terms of n describing the number of significant operations done with an initial call of Magicsort(A[0n1],n). Hint: write a recurrence whose general form is R(n)=aR(n/b)+f(n) where a,b are rational numbers and f(n) is a function of n. Justify why your recurrence is correct. Be sure to include the base case of your recursion. (c) Using this recurrence, prove that R(n)=2nlog3n when n1 using induction

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!