Median of sorted arrays

Here is my question
In satistics the median of a set of values is the value that lies in the middle when the values are arranged in sorted order.If the set has an even number of values, then the median is taken to be the average of the two middle values. Write a function that determines the median of a sorted array. The function should take an array of numbers and an integer indicating the size of the array and return the median of the values in the array. You may assume the array is already sorted.Use pointer notation whenever possible.

Figuring out how to start. Can any one give me an idea of how to start? I mean the pseudo code.

Thanks in advance!

Your array has 5 values. What is the index of the element in the middle of the array?

Your array has 4 values. What is the index of the element in the middle of the array?
The 4 is even. Did the index you just calculated point to the first or the second of the two elements in the middle? How to get the other index?

Your array has N values. What is the index of the element(s) in the middle of the array?
IF N is even, THEN something ELSE something.


What is the type of the elements of the array?
What is appropriate type for the median?
Topic archived. No new replies allowed.