Re: problem on medians



CBFalconer said:

Richard Heathfield wrote:
ak said:

what are the least no. of comparisons to find the medain of a set
of n integers ?

I presume you mean "median".

The answer is of course 0, which occurs when n is 0, 1, or 2. For
n = 0, there is nothing to compare, so no comparisons can occur.
When n is 1, there is only one value, which is its own median, so
no comparison is required. When n is 2, the median is given by the
sum of the two elements divided by 2, and again no comparison is
required.

Harumph. He didn't say "set of n non-negative integers". :-)

I didn't say he did. But n itself must be non-negative - or are you
claiming that you can have a set of integers that has fewer than no
members?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: problem on medians
    ... Richard Heathfield wrote: ... I presume you mean "median". ... When n is 1, there is only one value, which is its own median, so ... Posted via a free Usenet account from http://www.teranews.com ...
    (comp.programming)
  • Re: problem on medians
    ... I presume you mean "median". ... the median is given by the sum of the two ... with the highest and lowest members known. ... Richard Heathfield ...
    (comp.programming)
  • Re: finding the median of a list without sorting
    ... CBFalconer writes: ... I have seen some code which can find median of an odd numbered list ... I fail to see any difference in the median calculations for these. ... Keith Thompson kst-u@xxxxxxx ...
    (comp.programming)
  • Re: Finding the Median
    ... I presume you mean by the fifth column the one that starts off with 188, ... you appear to be missing the value for this column in the third row. ... I need the Median of Col 5, using a date range of Col 2. ... Sample Data ...
    (microsoft.public.excel.newusers)
  • Re: This lost data row
    ... I presume you mean 'quantile'? ... direct comparisons between the groups based on a single figure per ... A quantile is like a median, in that it's the closest value to that at ... percentile would be trhe 95th highest value. ...
    (uk.rec.motorcycles)