by Wizard » Sun Jun 28, 2009 8:26 am
no. You have two dimensions, but you have to be able to sort along one dimension to find the median.
You can find the median of the X coordinate, or you can find the median of the Y coordinate. If you want to find the median of both the X and Y, you need to have some function which will take the X and Y (two dimensions) and output a single number Z (one dimension). Then you can sort on that Z to find the median. The problem is what function it is you want to use. There are many different ways you can do it, and you haven't told us enough information to know which is the right one for you.
I am going to guess it's the length of the vector: ie, the distance from (0,0) to your (x,y). In that case, the function is
Z = sqrt(x*x + y*y);
I can't guarantee that that's what you need, but if this is an assignment, it probably is. Find the Z values for each of your coordinates, sort by that, and then find the median.
edit: wait, are you trying to find the median, or the mean? The median is the number in the middle, the mean is the average.