Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

There is a sorting algorithm, Stooge-Sort which is named after the comedy team, "The Three Stooges." if the input size, n, is 1or 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 below.

Algorithm StoogeSort(A, i, j ):

Input: An array, A, and two indices, i and j, such that 1 i j < n

Output: Subarray, A[i..j] ,sorted in nondecreasing order

1. n j i + 1 // The size of the subarray we are sorting

2. if n = 2 then

3. if A[i] > A[j] then Swap A[i] and A[j]

4. else if n > 2 then

5. m n/3

6. StoogeSort(A, i, j-m) // Sort the 1st part.

7. StoogeSort(A, i+m, j) // Sort the last part.

8. StoogeSort(A, i, j-m) // Sort the 1st part again.

9. return A

[10, Optional] Show that Stooge-sort is correct by Mathematical induction.

[10] Characterize the running time, T (n) , for Stooge-sort, using a recurrence equation.

[10] By means of Masters Theorem, determine an asymptotic bound for T (n).

[10, Optional] Solve the recurrence equation in 2 by means of Iterative Substitution method.

[10] Suppose we change the assignment statement for m (on line 5) to the following:

m max {1, n/4

[5] Characterize the running time, T(n), in this case, using a recurrence equation.

[5] Using the Masters Theorem, decide the asymptotic bound for T(n) in (A).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago