Question: Java Recursion Assignment. You may not use for or while. Any looping must be accomplished using recursion. Thank you. Consider an array of integers. You

Java Recursion Assignment. You may not use for or while. Any looping must be accomplished using recursion. Thank you.

Java Recursion Assignment. You may not use for or while. Any loopingmust be accomplished using recursion. Thank you. Consider an array of integers.

Consider an array of integers. You wish to find an approximate median. You have an idea: split the array into three pieces, find the approximate median of each piece, and then calculate the median of the three approximate medians (if you put the three approximate medians in sorted order, the one in the middle). There are a few details to consider. If we are trying to find the approximate median of one element, that element itself is its own median. If we are working with two elements, take the mean (average) which may be a fractional value. Otherwise, we are working with at least three elements. There are three possibilities for the number of elements: it is divisible by 3, it has a remainder of 1 when divided by 3, or a remainder of 2 when divided by 3. If the number of elements divided by 3 has a remainder of O: each piece should be n/3 elements. If a remainder of 1: the first piece should consist of the first In/3] elements, the last piece should consist of the last In elements, and the middle piece is the remaining rn/31 elements. In/31 rounds up. For example, if there were 4 elements, the first piece is the first element, the last piece is the last element, and the middle two elements constitute the middle piece.) If a remainder of 2: the first piece should consist of the first [n/31 elements, the last piece should consist of the last [n/31 elements, and the middle piece is the remaining In/3] elements. For example, if there were 8 elements, the first piece is the first 3 elements, the last piece is the last 3, and the middle two elements constitute the middle piece.) Consider an array of integers. You wish to find an approximate median. You have an idea: split the array into three pieces, find the approximate median of each piece, and then calculate the median of the three approximate medians (if you put the three approximate medians in sorted order, the one in the middle). There are a few details to consider. If we are trying to find the approximate median of one element, that element itself is its own median. If we are working with two elements, take the mean (average) which may be a fractional value. Otherwise, we are working with at least three elements. There are three possibilities for the number of elements: it is divisible by 3, it has a remainder of 1 when divided by 3, or a remainder of 2 when divided by 3. If the number of elements divided by 3 has a remainder of O: each piece should be n/3 elements. If a remainder of 1: the first piece should consist of the first In/3] elements, the last piece should consist of the last In elements, and the middle piece is the remaining rn/31 elements. In/31 rounds up. For example, if there were 4 elements, the first piece is the first element, the last piece is the last element, and the middle two elements constitute the middle piece.) If a remainder of 2: the first piece should consist of the first [n/31 elements, the last piece should consist of the last [n/31 elements, and the middle piece is the remaining In/3] elements. For example, if there were 8 elements, the first piece is the first 3 elements, the last piece is the last 3, and the middle two elements constitute the middle piece.)

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!