Question: Implement an animation of the merge sort algorithm of Chapter 14. Reimplement the algorithm so that the recursive calls sort the elements inside a subrange
Implement an animation of the merge sort algorithm of Chapter 14. Reimplement the algorithm so that the recursive calls sort the elements inside a subrange of the original array, rather than in their own arrays:

public void mergeSort(int from, int to) { if (from to) { return; } int mid (from + to) / 2; mergeSort (from, mid); mergeSort (mid + 1, to); merge (from, mid, to); } The merge method merges the sorted ranges a[ from] ... a[mid] and a[mid + 1] ... a[to]. Merge the ranges into a temporary array, then copy back the temporary array into the combined range. Pause in the merge method whenever you inspect an array element. Color the range a [from] ... a[to] in blue and the currently inspected element in red.
Step by Step Solution
3.30 Rating (153 Votes )
There are 3 Steps involved in it
The text in the image provides a skeleton for implementing the merge sort algorithm which sorts elem... View full answer
Get step-by-step solutions from verified subject matter experts
