#include#include #include void mergeSort(int *input,int low,int high) { if(low>=high) { return; } int mid=low+(high-low)/2; mergeSort(input,low,mid); mergeSort(input,mid+1,high); int *temp=(int *)malloc(sizeof(int)*(high-low+1)); int start1=low; int start2=mid+1; int k=0; while(start1<=mid&&start2<=high) { if(input[start1]<=input[start2]) { temp[k++]=input[start1++]; } else { temp[k++]=input[start2++]; } } while(start1<=mid) { temp[k++]=input[start1++]; } while(start2<=high) { temp[k++]=input[start2++]; } memcpy(input+low,temp,sizeof(int)*(high-low+1)); free(temp); } int* mySort(int *arr,int arrLen,int *returnSize) { mergeSort(arr,0,arrLen-1); *returnSize=arrLen; return arr; } int main() { int arr[5]={4,3,2,1,0}; int outputSize; int *output=mySort(arr,sizeof(arr)/sizeof(arr[0]),&outputSize); for(int i=0;i



