Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 inplace 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 printArraydouble arr int size
cout "The sorted list is: ;
for int i; i size; i
cout arri;
cout endl;
void mergedouble arr int l int m int r
Add your code below this line.
Add your code above this line.
void mergeSortdouble 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 arrn;
cout"Please input your numbers separated with space:" arri;
mergeSortarr n;
printArrayarr n;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started