Question: Recursion Intro Assignment. YOU HAVE TO DO IT USING HELPER METHOD AND NO IMPORTS ARE ALLOWED. You may not use for or while. Any looping
Recursion Intro Assignment. YOU HAVE TO DO IT USING "HELPER METHOD" AND NO IMPORTS ARE ALLOWED. You may not use for or while. Any looping must be accomplished using recursion. You may not declare static or non-static member fields only local or parameter variables allowed. Thanks!


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 ln/3] elements, the last piece should consist of the last In/3] elements, and the middle piece is the remaining [n/31 elements. [n/3] 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/3] 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 ln/3] elements, the last piece should consist of the last In/3] elements, and the middle piece is the remaining [n/31 elements. [n/3] 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/3] 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
Get step-by-step solutions from verified subject matter experts
