Question: Write a method named median: Write a method named median which calculate, and return, the median of an array of integers. The method should receive
Write a method named median:
Write a method named median which calculate, and return, the median of an array of integers. The method should receive as parameters, an array of integers and the filled size of the array.
Your method should assume that the array will contain some positive integers, filled in ascending order. This is a partially-filled array, where the number of items in the array may be less than the declared size of the array. The size parameter tells the method how many items are actually stored in the array.
The median should be calculated as a double value, as follows:
If there are an odd number of integers in the array, then the median is defined as the integer stored in the middle array position.
If there are an even number number of integers in the array, then the median is defined as the average of the integers stored in the two middle array positions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
