Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In statistic, when a set of values is sorted in ascending or descending order, i

ID: 3534164 • Letter: I

Question

  • In statistic, when a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values. Write a function that accepts as arguments the following:
    a) An array of integers.
    b) An integer that indicates the number of elements in the array.
    The function should determine the median of the array. This value should be returned as double. (Assume the values in the array are already sorted).

    Demonstrate your program prowess by using pointer notation instead of array notation in this function.
  • In statistic, when a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values. Write a function that accepts as arguments the following:
    a) An array of integers.
    b) An integer that indicates the number of elements in the array.
    The function should determine the median of the array. This value should be returned as double. (Assume the values in the array are already sorted).

    Demonstrate your program prowess by using pointer notation instead of array notation in this function.
In statistic, when a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values. Write a function that accepts as arguments the following:
a) An array of integers.
b) An integer that indicates the number of elements in the array.
The function should determine the median of the array. This value should be returned as double. (Assume the values in the array are already sorted).

Demonstrate your program prowess by using pointer notation instead of array notation in this function.

Explanation / Answer

double findMedian(int arr[], int n)

{

if(n%2==1)

return arr[n/2];

else

return ((arr[n/2-1]+arr[n/2])/2.0);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote