[Solved]3 20 Pts Recall Mergesort Algorithm Sorting Algorithm Takes E N Log N Time N Space Problem Q37177505


Please give answer in C++
3. (20 pts) Recall that the MergeSort algorithm is a sorting algorithm that takes e(n log n) time and Θ(n) space. In this problem, you will implement and instrument Mergesort then perform a numerical experiment that verifies this asymptotic analysis. There are two functions and one experiment to do this. (i) MergeSort (A,n) takes as input an unordered array A, of length n, and returns both an in-place sorted version of A and a count t of the number of atomic operations performed by MergeSort (ii) randomArray(n) takes as input an integer n and returns an array A such that for each 0 S i<, Ali is a uniformly random integer between 1 and n. (It is okay if A is a random permutation of the first n positive integers.) (a) (10 pts total) From scratch, implement the functions MergeSort and randomArray You may not use any library functions that make their implementation trivial. You may use a library function that implements a pseudorandom number gener- ator in order to implement randomArray Submit a paragraph that explains how you instrumented MergeSort, i.e., explain which operations you counted and why these are the correct ones to count. Show transcribed image text 3. (20 pts) Recall that the MergeSort algorithm is a sorting algorithm that takes e(n log n) time and Θ(n) space. In this problem, you will implement and instrument Mergesort then perform a numerical experiment that verifies this asymptotic analysis. There are two functions and one experiment to do this. (i) MergeSort (A,n) takes as input an unordered array A, of length n, and returns both an in-place sorted version of A and a count t of the number of atomic operations performed by MergeSort (ii) randomArray(n) takes as input an integer n and returns an array A such that for each 0 S i
Expert Answer
Answer to 3. (20 pts) Recall that the MergeSort algorithm is a sorting algorithm that takes e(n log n) time and Θ(n) space. In th… . . .
OR

