Question: Modify the merge sort algorithm so it is generic AND will sort the array in reverse. Also add a local variable count (make sure to

Modify the merge sort algorithm so it is generic AND will sort the array in reverse. Also add a local variable count (make sure to use the type long) that will count the number of elements comparisons that were performed for this sorting. Display the value of count before exiting this method. The method should have the following header: static void GenericReverseMergeSort(T[] arr) where T : IComparable

Provided Merge Sort algorithm:

static void MergeSort(int[] arr) { int[] tmp = new int[arr.Length];//only created once MergeSortHelper(arr, 0, arr.Length-1, tmp); }

static void MergeSortHelper(int[] arr, int startIdx, int endIdx, int[] tmp) { if(startIdx

} }

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!