Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question is asking to create a 3 way merge sort where the original array *a is broken in 3 subarrays recursively then put back

image text in transcribed

image text in transcribedThe question is asking to create a 3 way merge sort where the original array *a is broken in 3 subarrays recursively then put back together sorted, above is an example of 2 way merge sort.

Write a mergesort function which makes three recursive calls of length n/3 on an array of size n, and then merges three sorted arrays into one. void mergesort(int * a, int * aux, int length); You need a special case for arrays of length 2. The programming language is C or C++ #include #include /*mergesort: sort integer array a length ;standard mergesort /*sorts in increasing order, requires auxiliary array*/ void mergesort (int *a, int *aux, int length) { int i, ji, j2, temp ; //he declares the variables he will use her if(length>1) //if the size of the array is greater than 1, then we do the mergesort algorithn mergesort (a, aux, (length/2); recursive calls */ mergesort (a (length/2), aux, (length - (length/2))); for(int 1-0, ji -e, j2- (1ength/2) ;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Discuss all branches of science

Answered: 1 week ago