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: Theodore C. Belding
Subject: Re: Algorithm for finding Median: Got one or can you dissect this?
Date: Tue, 23 Mar 1999 01:14:04 -0500 (EST)

Hi-
Glad that helped.

To make the NR select routine work with standard C arrays, you can either
replace all occurrences of arr[index] with arr[index-1], or set arr=arr-1
at the beginning of the routine.  Or just remember to always pass arr-1 to
the routine, instead of arr, though that seems a bit error-prone.  Note
that k would still have the meaning 'kth smallest', and the routine would
return arr[k-1], not arr[k]. Also, n would still refer to the size of the
array, where the array now runs from 0 to n-1. To keep things straight in
my mind, I copy the comments from the NR book into my copy of the
routines, and note any changes I make. Otherwise, I'd go crazy.

It's annoying to have to do that, but I use such modified NR routines all
the time, without problems. Too bad they're not LGPL'd. 
-Ted

--
Ted Belding                               address@hidden 
University of Michigan Program for the Study of Complex Systems
Homepage: http://www-personal.umich.edu/~streak/
PGP key:  http://www-personal.umich.edu/~streak/pgp-key.html


                  ==================================
   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]