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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started