Menu

Problem 4 Consider Following Pseudocode Sorting Algorithm 0 1 N 1 Badsort 0 N 1 N 2 0 1 Sw Q43871294

Problem 4: Consider the following pseudocode for a sortingalgorithm, for 0 < α < 1 and n > 1

badSort(A[0… n-1])

if (n=2) and (A[0] > A[1])

swap A[0] and A[1]

else if (n>2)

m = [α*n]

badSort(A[0… m-1])

badSort(A[n-m… n-1])

badSort(A[0…m-1])

4a. Show that the divide and conquer approach of badSort failsto sort the input array if α ≤ 1/2.

4b. Does badSort work correctly if α = 3/4? If not, why? Explainhow you fix it.

4c. State a recurrence (in terms of n and α) for the number ofcomparisons performed by badSort.

4d. Let α= 2/3, and solve the recurrence to determine theasymptotic time complexity of badSort.

Expert Answer


Answer to Problem 4: Consider the following pseudocode for a sorting algorithm, for 0 < α < 1 and n > 1 badSort(A[0… n-1]) if (…

OR