Problem

Improvements. Run empirical studies to evaluate the effectiveness of each of the three imp...

Improvements. Run empirical studies to evaluate the effectiveness of each of the three improvements to mergesort that are described in the text (see exercise 1). Also, compare the performance of the merge implementation given in the text with the merge described in exercise 2 In particular, empirically determine the best value of the parameter that decides when to switch to insertion sort for small subarrays.

Exercise

Improvements. Implement the three improvements to mergesort that are described in the text on page 275: Add a cutoff for small subarrays, test whether the array is already in order, and avoid the copy by switching arguments in the recursive code.

Exercise 2

Faster merge. Implement a version of merge() that copies the second half of a[] to aux[] in decreasing order and then does the merge back to a[]. This change allows you to remove the code to test that each of the halves has been exhausted from the inner loop. Note: The resulting sort is not stable.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 2.2