Do any 3 out of the following 4 questions:
Consider the following sorting algorithm:
Procedure NewSort(i,j) {sort the elements from A[i] to A[j] }
if A[i] > A[j] then swap(A[i],A[j])
if i + 1 >= j then return
k = floor((j - i +1)/3) {Round down }
NewSort(i,j-k) {First two-thirds }
NewSort(i+k,j) {Last two-thirds }
NewSort(i,j-k) {First two-thirds again }
![]() |
![]() |
---|