Question: We define a combined array as a one-dimensional array, in which the elements at even indices (ie, 0, 2, 4, etc.) are sorted in ascending

We define a "combined array" as a one-dimensional array, in which the elements at even indices (ie, 0, 2, 4, etc.) are sorted in ascending order, and the elements at odd indices (ie, 1, 3, 5, etc.) are sorted in descending order. For example, the following array is a combined array (from left to right):

1 12 6 10 9 8 10 4 15 3

Write a recursive method whose signature - public int[][] split(int[] a) The method will receive as a parameter a combined array and will return a two-dimensional array with two rows, where row number 0 will have the members in the even indexes, sorted in ascending order, and row 1 will have the members from the odd indexes, sorted in ascending order. For example, after running the method with the above array, the following array will be returned: 12 10 8 4 3 15 10 9 6 1

It can be assumed that the array received as a parameter is indeed a combined array as explained, and is not empty. Do not use loops at all in this question! It is allowed to define private helper methods.

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!