Question: There is a sorting algorithm, Stooge-sort, which is named after the comedy team, The Three Stooges. if the input size, n, is 1 or 2,

There is a sorting algorithm, “Stooge-sort,” which is named after the comedy team, “The Three Stooges.” if the input size, n, is 1 or 2, then the algorithm sorts the input immediately. Otherwise, it recursively sorts the first 2n/3 elements, then the last 2n/3 elements, and then the first 2n/3 elements again. The details are shown in Algorithm 11.5. Show that Stooge-sort is correct and characterize the running time, T(n), for Stooge-sort, using a recurrence equation, and use the master theorem to determine an asymptotic bound for T(n). 

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

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.27 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The proof of correctness is a simple induction ... View full answer

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 Data Structures Algorithms Questions!