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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started