Question: For this problem we wish to construct a method named merge that will merge sorted arrays. For example, if you are given the following two
For this problem we wish to construct a method named merge that will merge sorted arrays. For example, if you are given the following two arrays:
int [] a = {1 , 3 , 5 , 7}; // Note that numbers are ascending ( sorted )
int [] b = {2 , 4 , 6 , 8, 10}; // Note that it's sorted too
And then did:
int [] mergedArrays = merge (a , b );
The result (mergedArrays) would look like:
[1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10]
Once merge is complete we should have an array with all of the elements of the two given arrays in sorted order. For this problem, we can assume that the arrays provided as parameters are each sorted individually before the merge is called. We should assume that the two arrays can be any length and their lengths may differ from each other. Complete the method signature with the most appropriate choices and the method's body:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
