search

# Fun With Mergesort Given the recursive mergesort function below Mod

Content type
User Generated
Rating
Showing Page:
1/2
Fun With Mergesort. Given the recursive mergesort
function below. Modify the msort function such that, msort
calls msort for sub arrays with more than 1024 elements,
and msort calls bsort for sub arrays with 1024 or less
elements. Assume both functions operate on the same
global array. int data[4294967296];//REALLY BIG array
Void bsort(int f, int l);//Forward declaration
Solution
void msort(int f, int l) {
if(l-f <= 1024){
bsort(f,l);
} else{
int m;
if(f<l) {
m = (f + l)/2;
msort(f,m);
msort(m+1,l);
merge(f,m,l);
}
}
}

Showing Page:
2/2

Unformatted Attachment Preview
Fun With Mergesort. Given the recursive mergesort function below. Modify the msort function such that, msort calls msort for sub arrays with more than 1024 elements, and msort calls bsort for sub arrays with 1024 or less elements. Assume both functions op erate on the same global array. int data[4294967296];//REALLY BIG array Void bsort(int f, int l);//Forward declaration Solution void msort(int f, int l) { if(l-f ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
Awesome! Perfect study aid.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4