Question: the merge algorithm given in class, us this to create a mergesort algorithm as described in part a Consider the following merge sort algorithm for

 the merge algorithm given in class, us this to create a

the merge algorithm given in class, us this to create a mergesort algorithm as described in part a

mergesort algorithm as described in part a Consider the following "merge sort"

Consider the following "merge sort" algorithm for a list of size n, where n is even: Remove the last two elements and recursively sort the remaining n - 2 elements. Sort the two removed elements with one comparison. Form the final sorted list by using the merge algorithm from class to merge the two sorted elements and the sorted list (of size n - 2). (a) Write the algorithm in pseudocode using recursion. You can assume that you have available the merge routine. (It should look very similar to the Merge Sort algorithm we did in class.) (b) Give a recurrence for the exact number of comparisons this algorithm uses

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!