Question: On problem with mergesort is that it constantly needs a new temporary array. One solution to the problem is to rewrite the mergesort according to
On problem with mergesort is that it constantly needs a new temporary array. One solution to the problem is to rewrite the mergesort according to the following specification:
![void mergesort( int data[ ], int first, int n, int temp[ ] ); // Precondition: data[first] through // data[first+n-1] are array elements in no // particular order. The temp array has // locations temp[first] through // temp[first+n-1]. // Postcondition: The elements // datalfirst] through data[first+n-1] // have been rearranged so](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1605/8/5/6/1985fb76bc6d4a731605856197578.jpg)
void mergesort( int data[ ], int first, int n, int temp[ ] ); // Precondition: data[first] through // data[first+n-1] are array elements in no // particular order. The temp array has // locations temp[first] through // temp[first+n-1]. // Postcondition: The elements // datalfirst] through data[first+n-1] // have been rearranged so that they are // ordered from smallest to largest. The array // elements temp[first] through // temp[first+n-1] have been used as // temporary storage.
Step by Step Solution
3.38 Rating (185 Votes )
There are 3 Steps involved in it
void mergeint data int first int mid int last in... View full answer
Get step-by-step solutions from verified subject matter experts
