All Sorts of Sorts 
Author Message
 All Sorts of Sorts

 Date: 02-26-90 (22:34)              Number: 2971 (Echo)
   To: STEVE PALINCSAR               Refer#: NONE
 From: BILL MCCARTHY                   Read: NO
 Subj: SHELL SORT                    Status: PUBLIC MESSAGE

 I uploaded HS-SHELL.ZIP which contains both a selection
 and shell sort in HS/Forth.

 On a 16 Mhz 386, I got the following timings (seconds)
 sorting random 40 character strings.

 Items   Selection  Shell

  100        .44      .11
  200       1.58      .21
  300       3.61      .43
  400       6.37      .65
  500       9.98      .82

 You mentioned trying insertion sort.  That method is
 awful except when adding to a sorted set of when the
 elements of the set are all near their final positions
 (such as a cleanup to a minimum partition quicksort).
This message came from GEnie via willett through a semi-automated process.

Sun, 16 Aug 1992 07:55:25 GMT  
 All Sorts of Sorts
Category 3,  Topic 37
Message 31        Sun Mar 04, 1990
F.SERGEANT [Frank]           at 21:52 CST

 To Steve & Ian,

SP> : LOOP_DEMONSTRATION  ( n2 n1 -- ) SP> \ That is, both the inner and outer
loop limits are on the stack SP> \ before this word executes.  You could put
them there by fetching SP> \ from a couple of variables, or whatever other
means you like. SP>    1 DO        ( Takes n1 from param stack, puts in on
Rstack ) SP>       1 DO     ( Takes n2 from param stack, puts it on Rstack )
SP>           <SOMETHING>  ( whatever you want to execute ) SP>       LOOP SP>

  Nope, the above will not work (unless n1 is 1).  The 2nd & subsequent
passes thru the outer loop will have no limit available on the stack  for the
inner loop.  You need a DUP after the 1st DO and a DROP after  the last LOOP.

 Also, I keep seeing these "1"s as beginning indexes for your loops in  these
messages.  Presumably you want to say something like  10 STARS  and have your
word STARS print ten of 'em.  If you define STARS with a  built-in index of 1,
you'd have to say 11 STARS to get 10 of 'em.  

   : STARS  ( #-of-stars-desired - )   0  DO   STAR   LOOP  ;
   : STARS  ( 1-more-than-#-of-stars-desired  - )  1  DO STAR LOOP ;

 On the other hand, you might want to use a built-in index of 1 when  you plan
to use the index inside of the loop, eg for addressing a one  based array.  I
would think the more common situation would be to use a  zero based array, in
which case you would still use a starting index   of 1.  

 Any questions?  (By the way, I don't use DO LOOP anymore, just FOR  NEXT.)

  -- Frank
This message came from GEnie via willett through a semi-automated process.

Sat, 22 Aug 1992 09:04:24 GMT  
 All Sorts of Sorts

 Date: 03-06-90 (18:12)              Number: 3005 (Echo)
   To: FRANK SERGEANT                Refer#: NONE
 From: IAN GREEN                       Read: NO

    As you explained it, I am a bit confused. In Modula-2, I can use what
 is called a subrange to index arrays, consequentky I often use indicies
 whick are more meaningful, such as the following:

    Sales: ARRAY [1970..1990] OF REAL;

 If I pass that array to what is called an open array procedure, 1970
 becomes 0 (the arrays internally are zero indexed). Consequently I am
 oriented to zero-based arrays, simply because I make such extensive use
 of open-array parameters.

 Now you mentioned that you use FOR-NEXT over DO-LOOP so could you
 illustrate examples of nested loops that use the control variables
 inside, say in a shell-sort of an array.

 Ian Green

 NET/Mail : British Columbia Forth Board - Burnaby BC - (604)434-5886  
This message came from GEnie via willett through a semi-automated process.

Mon, 24 Aug 1992 09:02:38 GMT  
 [ 3 post ] 

 Relevant Pages 

1. Sort (List sorts...)

2. Binary Sort/Merge Sort in awk

3. Sort of Sorts

4. All Sorts of Sorts

5. All Sorts of Sorts

6. All Sorts of Sorts

7. Bubble sort/Selection sort help neded.

8. Qsort, Merge sort, Radix sort in prolog Help!

9. UNIX sort exponents (bc|sort)

10. ANN: New release of S.C.A. Micro Templates (Browse Header Sort and Reverse Sort Template)

11. Straight Insertion Sort and Binary Insertion Sort

12. Sorting a file w/o SORT verb


Powered by phpBB® Forum Software