Write a C++ program for sorting an array A of n integers using the Merge Sort algorithm.
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a C++ program for sorting an array A of n integers using the Merge Sort algorithm. First you need to implement both the MERGE‐SORT and MERGE algorithms (shown below). The main() function of your program must carry out the following tasks:
1. Ask the user to input the value of n, where 1< n ≤ 50
2. Fill A with random integers in the range 0 to 100. To generate such random numbers, you need to use the header. Check the following link for an example:
http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
3. Call the MERGE‐SORT function to sort the contents of A (where MERGE‐SORT needs to call the MERGE function).
4. Display on the screen the contents of the sorted array A.
Related Book For
Posted Date: