Consider the following recursive algorithm:

    if A[i] > A[j] then exchange A[i] and A[j];
    if i+1 >= j then return;
    k = (j-i+1) / 3; //integer division
    Unknown (A,i,j-k);

a) What does Unknown(A,1,n) do?

b) Prove that it indeed does what you have said in (a).

c) Give a recurrence for the worst-case time of Unknown(A,1,n) and solve it in big Theta.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

a) The given algorithm sorts the array 1..n, by taking first 2/3 of array, then last two 2/3 of the array and in the end first 2/3 again (this because of the value of k, which is about 1/3 of the array length)....

By purchasing this solution you'll be able to access the following files:

50% discount

$10.00 $5.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Data Structures and Algorithms Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats