Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 401(k) feature?

Answered: 1 week ago

Question

Question Can employees make contributions to a profit sharing plan?

Answered: 1 week ago