🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1819

Re: qsort(), bsearch(), and rude comparison functions

#1819
From: Evan Marshall Manning
Date: Tue, 09 Oct 1990 23:16
17 lines
1476 bytes
flee@guardian.cs.psu.edu (Felix Lee) writes:

>A pathological comparison function might shuffle the array being
>sorted each time it's called, in which case qsort() may never
>terminate.  Is this prohibited?

I myself have used qsort with a comparison function which used
rand() to generate a positive or negative number.  I was prepared
for it to go on forever, but it terminated with the array fully
shuffled.

***************************************************************************
Your eyes are weary from staring at the CRT for so | Evan M. Manning
long.  You feel sleepy.  Notice how restful it is  |      is
to watch the cursor blink.  Close your eyes.  The  |manning@gap.cco.caltech.edu
opinions stated above are yours.  You cannot       | manning@mars.jpl.nasa.gov
imagine why you ever felt otherwise.               | gleeper@tybalt.caltech.edu
Technical Details
Message-ID: <1990Oct9.231612.10881@nntp-server.caltech.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!decwrl!shelby!eos!data.nas.nasa.gov!mustang!nntp-server.caltech.edu!manning
References: <1990Oct6.013443.5364@twinsun.com> <1990Oct9.062455.21197@sq.sq.com> <Fex+yrm2@cs.psu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!decwrl!shelby!eos!data.nas.nasa.gov!mustang!nntp-server.caltech.edu!manning
From: manning@nntp-server.caltech.edu (Evan Marshall Manning)
Newsgroups: comp.std.c
Subject: Re: qsort(), bsearch(), and rude comparison functions
Message-ID: <1990Oct9.231612.10881@nntp-server.caltech.edu>
Date: 9 Oct 90 23:16:12 GMT
References: <1990Oct6.013443.5364@twinsun.com>  <1990Oct9.062455.21197@sq.sq.com> <Fex+yrm2@cs.psu.edu>
Organization: California Institute of Technology, Pasadena
Lines: 17