Question: 2. Consider the following sorting algorithm. For simplicity, we'll assume the problem input size n is always a power of 2. COOLSORT(A[ 1 .. n]):

2. Consider the following sorting algorithm. For
2. Consider the following sorting algorithm. For simplicity, we'll assume the problem input size n is always a power of 2. COOLSORT(A[ 1 .. n]): if n > 1 COOLSORT(A[1 .. n/2]) COOLSORT(A[n/2 + 1 .. n]) COOLMERGE(A[ 1 .. n]) COOLMERGE(A[ 1 .. n]): if n = 2 if A[ 1 ] > A[2] swap A[1] A[2] else for i - 1 to n/4 ((swap 2nd and 3rd quarters)) swap A[i + n/4] A[i + n/2] COOLMERGE(A[ 1 .. n/2]) ((recurse on left half)) COOLMERGE(A[n/2 + 1 .. n]) ((recurse on right half)) COOLMERGE(A[n/4 + 1 .. 3n/4]) ({recurse on middle half)) (a) (3 out of 10) Let C(n) be the running time for COOLMERGE(A[1 .. n]). State a recurrence definition for C(n). You do not have to solve the recurrence for this part of the problem. (b) (3 out of 10) What is the running time of COOLMERGE(A[1 .. n])? You should assume your solution to part (a) is correct. (c) (4 out of 10) What is the running time of COOLSORT(A[1 .. n])? You should assume your solution to part (b) is correct

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 Mathematics Questions!