Question: Your Task: Your task is to complete the function merge ( ) which takes arr [ ] , l , m , r as its

Your Task:
Your task is to complete the function merge() which takes arr[], l, m, r as its input parameters and modifies arr[] in-place such that it is sorted from position l to position r, and function mergeSort() which uses merge() to sort the array in ascending order using merge sort algorithm. I am supposed to fill in the incomplete code where it says "Add your code below this line". The incomplete code is: #include
using namespace std;
// Function to print an array
void printArray(double arr[], int size)
{
cout "The sorted list is: ";
for (int i=0; i size; i++)
cout arr[i]"";
cout endl;
}
void merge(double arr[], int l, int m, int r)
{
//Add your code below this line.
//Add your code above this line.
}
void mergeSort(double arr[], int l, int r)
{
//Add your code below this line.
//Add your code above this line.
}
int main()
{
int n;
cout"How many numbers are you going to sort?"> n;
double arr[n+1];
cout"Please input your numbers separated with space:"> arr[i];
mergeSort(arr,0, n-1);
printArray(arr, n);
return 0;
}
 Your Task: Your task is to complete the function merge() which

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!