[futurebasic] Re: [FB] Quick Sort for Numb

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1999 : Group Archive : Group : All Groups

From: Doug Hull <doug_hull@...>
Date: Tue, 08 Jun 1999 11:25:07 -0500
        Reply to:   RE>[FB] Quick Sort for Numbers?

Here is a little sort sorting an array:  gtempcntr# is how many numbers are
being sorted!  glatency#() is the array of values being sorted!  Hope this
helps!  Not for sure on 250,000 vals.

LOCAL FN getmedianlatency                         'sort latency
  n = gtempcntr# : i = 0 : j = 0 : k = 0 : s# = 0 : i = n / 2
  DO
    j = i
    DO
      j = j + 1
      k = j - i
      DO
        LONG IF glatency#(k) > glatency#(k + i)
                  s# = glatency#(k) : glatency#(k) = glatency#(k + i)
                  glatency#(k + i) = s# : k = k - i
        XELSE
                  k = 0
        END IF
      UNTIL k <= 0
    UNTIL j = n
    i = i / 2
  UNTIL i <= 0
'whats the middle median value
'  LONG IF USR EVEN(gtempcntr#) - gtempcntr# = 0
'    gmedlatency# = (glatency#(gtempcntr#/2) +
'    glatency#((gtempcntr#/2)+1))/2
'  XELSE
'    gmedlatency# = glatency#(INT((gtempcntr#/2)+1))
'  END IF
END FN

Doug

--------------------------------------
Date: 06/08/1999 11:07 AM
To: Doug Hull
From: futurebasic@...

Do anybody have anything that will do for numbers what Tedd's quicksort
does for strings?

I need to be able to sort up to 250,000 values from smallest to largest.

I have an array of XYZ points needing to be sorted by Z's, and I was
thinking that my ZBuf array (array 2) could just store a pointer to the
element of the array (the N,j,i, whatever) instead of my having to have a
whole array to copy all the points over to in order.

So for example, if XYZ.Z(3) is "24" and XYZ.Z(4) is "7" the other array
would have data of 4,3,... so on (unless something was inbetween those of
course). I can just cross reference the pointer to the original array data
when plotting the points. But I guess it might still take a secondary array
to hold things temporarily for the sort.

Anything that would work quickly for this high amount of numbers would be
nice no matter what the setup though. I tried the FB Bubble sort, but it
took about 6 years to do 250,000 points. Heck, it took 6 years to do just
50,000 points.


Robert Covington



--
To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>


------------------ RFC822 Header Follows ------------------
Received: by parsons.lsi.ukans.edu with SMTP;8 Jun 1999 11:07:12 -0500
Received: (qmail 18964 invoked by alias); 8 Jun 1999 15:56:24 -0000
Mailing-List: contact futurebasic-help@...; run by ezmlm
Reply-To: futurebasic@...
Precedence: bulk
X-No-Archive: yes
Delivered-To: mailing list futurebasic@...
Received: (qmail 18943 invoked from network); 8 Jun 1999 15:56:22 -0000
X-Sender: t88@...
Message-Id: <l03130301b382f882e5c0@[207.218.59.2]>
In-Reply-To: <b56e6562.248e8d85@...>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Tue, 8 Jun 1999 08:57:31 -0800
To: futurebasic@...
From: Robert Covington <t88@...>
Subject: [FB] Quick Sort for Numbers?