home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!gatech!paladin.american.edu!auvm!UCSFVM.BITNET!GOMBERG
- Message-ID: <REXXLIST%92082917272526@UGA.CC.UGA.EDU>
- Newsgroups: comp.lang.rexx
- Date: Sat, 29 Aug 1992 14:14:39 PDT
- Sender: REXX Programming discussion list <REXXLIST@UGA.BITNET>
- From: Dave Gomberg <GOMBERG@UCSFVM.BITNET>
- Subject: Re: compare a number with a stem
- In-Reply-To: Message of Sat, 29 Aug 1992 22:38:03 MSZ from <LHINNER@DGOGWDG1>
- Lines: 10
-
- Here is some very fast code for searching for how many in a sorted stem
- are bigger than a:
-
- $TOP=s.0+1; $BOT=1 -1; /* ABOVE HIGHEST */
- DO WHILE($TOP>$BOT+1);$MID=($TOP+$BOT)/2; /* TILL NONE LEFT */
- IF a >= s.$MID THEN $BOT=$MID; ELSE $TOP=$MID; END;
- /* Initially, s.$bot<=a<s.$top */
- SAY (s.0-$top+1)/s.0*100 'percent of the values are greater than' a'.'
-
- This is O(LN(S.0)). Dave
-