Menu

[solved] – Question 80327

In an experiment, the Merge Sort algorithm will be modified into a 3-MergeSort algorithm in the hope of getting a new algorithm that is more efficient. Basically, the modification made is that the input array of length n is no longer split into 2, but into 3, so that each new array created will have a length of n/3. Answer the following questions:

To accommodate the above modification, the Merge function will be changed to a Merge3 function which no longer accepts input in the form of 2 arrays, but 3 arrays (which have been ordered). Consider the implementation of the Merge3 function in the following pseudocode:
function Merge3(array A, array B, array C):
AB = Merge(A, B)
return Merge(AB, C)

* The Merge function called in the Merge3 function above is the same Merge function as the standard Merge Sort algorithm, which accepts 2 sorted arrays as input.

Calculate the time complexity of the Merge3 function! Use Big O notation with m as input, where m is the total sum of the lengths of the arrays A, B, and C!

Calculate the time complexity of the 3-MergeSort algorithm as a whole! Use Big O notation with n as input, where n is the length of the initial input array!

When compared to the time complexity of the standard Merge Sort algorithm, can the 3-MergeSort algorithm be said to be significantly more efficient?

Suppose the 3-MergeSort algorithm created above is run on the following array: [4, 8, 2, 9, 1, 7, 5, 3, 6]. What will the contents of the array look like when the three outermost recursion function calls have finished, but just before the most recent Merge3 function executed?

Expert Answer


Answer to In an experiment, the Merge Sort algorithm will be modified into a 3-MergeSort algorithm in the hope of getting a new algorithm……

OR


Leave a Reply

Your email address will not be published. Required fields are marked *