swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Algorithm for finding Median: Got one or can you dissect this?


From: Marcus G. Daniels
Subject: Re: Algorithm for finding Median: Got one or can you dissect this?
Date: 22 Mar 1999 13:32:58 -0800

>>>>> "PJ" == Paul E Johnson <address@hidden> writes:

PJ> If you have a nice, quick algorithm to find medians, please give it to
PJ> me, because I've tried pretty hard with this one.

Fundamentally, it should be possible to QSort an array copy of
a collection an then do:

  lhs = (n - 1) / 2;
  rhs = n / 2;

  if (n == 0)
    return 0.0;

  if (lhs == rhs)
    median = (lhs == rhs) ? sorted[lhs] : (sorted[lhs] + sorted[rhs]) / 2.0;

Sorry, SwarmFest pressures prevent me from looking at your test case now.

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]