Question: Hallo! I have this task, I cann't answer, I need help please! My Task is: Write a method a- public static int [] mergeArrays (int

Hallo!

I have this task, I cann't answer, I need help please!

My Task is:

Write a method a- public static int [] mergeArrays (int [] a, int [] b) {} as for two given sorted arrays, constricting a new array. Results should be a sorted array. You should not use finished sorting methods. You should put the sorted array together by always moving the value of value, minimum (a [i], b [j]). The new array has the size of a + b. For example, if a = {2,5,7} and b = {1,3}, the reword c = {1,2,3,5,7} method should first check if any of arrays a and b is zero. In that case, the method should throw an Exception object. Keep in mind that a.length ! = B.length. The method should return the new array.

b- Write a method isSorted () that checks whether an array is sorted or not. Returns true if sorted otherwise false. c - Write a program that automatically tests your methods as follows: Create 2 arrays of different sizes (1-25 elements) and fill it with random values ??in the 1-100 range. -sorts the arrays using the java.util.Arrays.sort method (int [] a) -aropa mergeArrays () call isSorted () print if margeArrays () algorithm has passed the test or not. Make sure your program does this 20 times. Are all the arrays ready? -In addition, try the mergeArrays () algorithm when either or both of the arrays are zero. What then? Ending the code so that if the array is null, the method should throw an Exception object.

Thank you!

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