Question: Write a function called worstBasicOps (in python) to calculate the maximum number of key comparisons of a merge sort algorithm. Assume this is for a

Write a function called worstBasicOps (in python) to calculate the maximum number of key comparisons of a merge sort algorithm.

Assume this is for a list the size of n, where n is a power of 2 (n = 2^k), this function returns w(n), aka the worst case or maximum number of key comparisons, as a float.

worst case of merge sort does n-1 key comparisons because there's no need to compare the last element to itself therefore, for worstBasicOps, assume that the recurrence relation is: w(1) = 0 for n>1, n a power of 2 is: w(n) = 2*w(n/2) + n - 1 Hint: starting with given w(1), calculate w(2), w(4), etc. until you find a pattern from this pattern, find a closed form solution. Then use induction to prove it's true implement here the candidate solution

therefore, for worstBasicOps, assume that the recurrence relation is: w(1) = 0 for n>1, n a power of 2 is: w(n) = 2*w(n/2) + n - 1 Hint: starting with given w(1), calculate w(2), w(4), etc. until you find a pattern from this pattern, find a closed form solution. Then use induction to prove it's true implement here the candidate solution

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!