Question: 13. Write an algorithm that sorts a list of n items by dividing it into three sublists of about n/3 items, sorting each sublist recursively

13. Write an algorithm that sorts a list of n items by dividing it into three sublists of about n/3 items, sorting each sublist recursively and merging the three sorted sublists. Analyze your algorithm, and give the results under order notation.

Not sure if I did this right. Please correct and help with the analyzing algorithm and give the results under order notation. Please be in detail too.

MergeSort( A[1..m], B[1..n], C[1..m+n])

1) i := j := k := 1

2) IF i > m

3) THEN Copy the rest of B into C

4) ELSE Copy the rest of A into C

5) WHILE i m AND j n DO 6) IF A[i] < B[j]

7) THEN C[k] := A[i], i++, k++

8) ELSE C[k] := B[j], j++, k++

-or-

MergeSort(array, i , n) 1) IF n>1 2) MergeSort(array, i , n/3) 3) MergeSort(array, i+ n/3, n-n/3) 4) MergeSort(array, i+n/3, n-n/3) 5) Merge(array, i, n/3,n-n/3)

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!