Question: A professor has proposed the following elegant sorting algorithm: Sort(A,i,j) { Let A be an array containing n distinct numbers, and let i,j be integers

 A professor has proposed the following "elegant" sorting algorithm: Sort(A,i,j) {

A professor has proposed the following "elegant" sorting algorithm: Sort(A,i,j) { Let A be an array containing n distinct numbers, and let i,j be integers such that 1i,jn. Sort (A,i,j) sorts A[i],A[i+1],,A[j] in non-decreasing order. } begin if A[i]>A[j] then exchange A[i]A[j]; if i+1j then return; k(ji+1)/3; RRound down Sort(A,i,jk); First two-thirds are sorted Sort(A,i+k,j); \{Last two-thirds are sorted Sort(A,i,jk); First two-thirds are sorted again \} end; For a real number x,x denotes the maximum integer m satisfying mx. Answer the following questions. (1) Prove that Sort (A,1,n) correctly sorts the n elements of the input array A in non-decreasing order. (2) Give a tight asymptotic ( -notation) bound on the worst-case running time of Sort. You may ignore round-up or round-down in the evaluation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!