Question: Problem 2 . Write an algorithm called mergesort 3 that sorts an array S of n ints by dividing the array into three subarrays of

Problem 2. Write an algorithm called mergesort3 that sorts an array S of n ints by
dividing the array into three subarrays of approximately n3 ints,
sorting each subarray using recursion, and
merging the three sorted subarrays.
A few notes: this algorithm will be very similar to mergesort (page 59), except that we are splitting
the array into three subarrays. The algorithm's heading should look like this:
void mergesort3(intn, int S[])
You may assume that you already have an algorithm
void merge( int h, int m, int t, const int U[], const int V[], const int W[], int S[])
that merges an array U of size h, an array V of size m, and an array W of size t into the sorted array
S. So you don't have to write merge, you just need to call it within your mergesort 3 algorithm.
Look at picture for better reference.
Problem 2 . Write an algorithm called mergesort 3

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 Programming Questions!