Question: Consider the Stooge-sort algorithm, shown in Algorithm 11.5, and suppose we change the assignment statement for m (on line 6) to the following: m
Consider the Stooge-sort algorithm, shown in Algorithm 11.5, and suppose we change the assignment statement for m (on line 6) to the following:
m ← max{1, [n/4]}
Characterize the running time, T(n), in this case, using a recurrence equation, and use the master theorem to determine an asymptotic bound for T(n).
Algorithm 11.5
![Algorithm StoogeSort(A, i, j): Input: An array, A, and two indices, i and j, such that 1 < i 2 then m - [n/3] StoogeSort(A, i, j – m) StoogeSort(A, i+m, j) StoogeSort(A, i, j – m) // Sort the first part // Sort the last part // Sort](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1594/7/9/9/1705f0eb442013911594799163510.jpg)
Algorithm StoogeSort(A, i, j): Input: An array, A, and two indices, i and j, such that 1 < i 2 then m - [n/3] StoogeSort(A, i, j m) StoogeSort(A, i+m, j) StoogeSort(A, i, j m) // Sort the first part // Sort the last part // Sort the first part again | return A Algorithm 11.5: Stooge-sort.
Step by Step Solution
3.38 Rating (157 Votes )
There are 3 Steps involved in it
The recurrence for Tn is Tn 3T3n4 bn or Tn 3... View full answer
Get step-by-step solutions from verified subject matter experts
