home *** CD-ROM | disk | FTP | other *** search
- 100 ' SHELSORT Submitted by Bob Noble
- 110 '
- 120 ' This program sorts ten random integers between 1 and 100 in
- 130 ' ascending order. It is a binary sort and is relatively fast.
- 140 ' The coding can esaily be converted to handle strings for gen-
- 150 ' eral use.
- 160 '
- 170 ' I have modified this listing for use in IBM PC BASIC from
- 180 ' the following source:
- 190 '
- 200 ' Grillo, John P. and J.D. Richardson, DATA MANAGEMENT
- 210 ' TECHNIQUES, Dubuque, Iowa: Wm. C. Brown Co., 1981.
- 220 '
- 230 CLS: KEY OFF: PRINT: DIM D(100): DEFINT D: RANDOMIZE
- 240 PRINT
- 250 FOR I = 1 TO 10: D(I) = RND*100: NEXT I
- 260 '
- 270 PRINT "Pass # Position ->";
- 280 FOR I = 1 TO 10: PRINT TAB(20 + I * 4);I;: NEXT I
- 290 PRINT: PRINT: P = 0: N = 10: GOSUB 460
- 300 GOSUB 340
- 310 GOTO 490
- 320 '
- 330 ' * * * * * * * * * * Shell Sort * * * * * * * * * *
- 340 P = N
- 350 IF P <= 1 THEN RETURN
- 360 P = INT(P/2): M = N-P
- 370 F = 0
- 380 FOR J = 1 TO M
- 390 X = J+P
- 400 IF D(J) > D(X) THEN T = D(J): D(J) = D(X): D(X) = T: F = 1
- 410 NEXT J
- 420 IF F > 0 THEN 370
- 430 GOSUB 460: GOTO 350
- 440 '
- 450 ' * * * * * * * * * * Print Results * * * * * * * *
- 460 PRINT P; TAB(7); "D";
- 470 FOR I = 1 TO N: PRINT TAB(20+I*4); D(I);: NEXT I
- 480 PRINT: RETURN
- 490 PRINT: KEY ON: END
- *
- 460 PRINT P; TAB(7