[futurebasic] Re: [FB] ShellSort Progress :)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1998 : Group Archive : Group : All Groups

From: Mark Arnold <mda515t@...>
Date: Tue, 15 Dec 1998 07:52:22 -0600
Thanks for the clarification, Robert. There are so many ways to order a
file and so many ways to implement the procedures, I don't think I'll ever
get it all sorted out (Sorry, couldn't help it.)

I've figured out how to implement a counter, but I'd like to calculate the
number of passes through the loop instead of brute-forcing it. Right now,
here's what I'm having to do:

  split& = numRecs& / 2
  max&=0
  WHILE split& <> 0
    elemNum& = numRecs& - split&
    FOR thisElem& = 0 TO elemNum&
      INC(max&)
    NEXT
    split& = split& / 2

  WEND


It's been a long time since I studied any math, but I'm pretty sure there's
a formula for calculating this. Any ideas?

TIA

-mark-
>
>The sorting method is not QuickSort, but a Shell sort. In the Quicksort
>algorithm the data is recursively partitioned, whereas in Shell sorting,
>comparisons and exchanges are made across a gap (split&) which is initially
>wide and then progressively narrowed. In fact the "FN QuickSort" given by
>Mark clearly derives from the FB examples program Shellsort.bas.
>
>Although a Shell sort performs well on medium-sized problems (a few hundred
>elements), in really big problems Quicksort or Heapsort will be much faster.
>
>Robert Purves