' +JJJJ ?\>m0M='+l> /+l   d']6@5L&]655]6LF%5 & "L}"BB5L&]6 X  `6 7777777 7777JJJJx 77L? L7877777777 776i 7 7867 7`77 777777`x =(`(8`5775I7`B` 76`77`>J><;VU<)?<`8'x0|<&HhHh 8 8 8 8V&` aI꽌ɪVɭ&Y:&<&Y:&;: 꽌ɪ\8`&&꽌ɪɖ'*&%&,E'зЮ꽌ɪФ`+*xS&x'8*3Ixix&& 8 9: :' 9: :& :x)*++`FG8`0($ p,&"ųųೳŪŪųųij  !"#$%&'()*+,-./0123456789:;<=>?8  1 '" *"( (9"1 ( ,.(0# 2  /#0/#0 *?'#07#000'#07#0:"4<*55**5*%5)1)1)1)'#0/#0*5*75**5*:5/#0/#0'#07#0:::*::'#07#0"):$(%"%:$(%"%$$2%4%$$2%4%$(2()!)E(!8b $!H(+ "@H !D)"E` @ $ C ` DQ &J80^݌Hh < <݌ < < h < < < <`HJ>݌h Hh݌`葠葠ȔЖȔЖȠHIHHHHhHH݌hHhHh݌H6 (G FG HZXj 80x D9$xxH` >( Z>h Z>L=.xxH >hh@(LH>9L>HH/Hh/ H?-З( 8(& 8$8 H` *8HNx`* >x$50x*$50xL9JJJJ`HHjf5 >h $50x`HA>VD;;P >(ED Z> ?$0x8x D9- 8DD# H8`?E Vˆʎ55L $ 5 55555 &a*5`*5` "L&5_*b*JL%u**Lz%`** $  Q(lXJ̥KlV $  Q(lV eօ3L e3L &%R*L &%Q*L d' "L4% N'e*)n*5 5 &`@-e*f*f* 5 "L# "5f*`L %.* *t*Q*L$ %L&*L` "O**P**u** d' "L% N'e*)n*o*o*n* &8ɍ` ^&f\*555L& ^&NR* & "R*ΩL&)\*Z* ʽ LH*v 3h`0h8` " ['L & N'С55 &5`*A*@` +5L^6L65`  \* ?*0 '\* '  Q( ^&\*lZl^?*c*q)H c*h`f*5h*5j*555@O*AP*`u*@`@5&`Q*R*`E 'Ls' ' ' @DAE@u*`8` %@ @A@`@`**@*A`M5 ) "L&`8@AW*c*@8@-@HAȑ@hHȑ@ȑ@hHȑ@Ȋ@c*h8&ȑ@Hȑ@Ah@L'Hȑ@ȑ@* htphso`hMhL`9V*8U*897T*6S*67`INILOASAVRUCHAIDELETLOCUNLOCCLOSREAEXEWRITPOSITIOOPEAPPENRENAMCATALOMONOMOPRINMAXFILEFINBSAVBLOABRUVERIF!pppp p p p p`" t""#x"p0p@p@@@p@!y q q p@  LANGUAGE NOT AVAILABLRANGE ERROWRITE PROTECTEEND OF DATFILE NOT FOUNVOLUME MISMATCI/O ERRODISK FULFILE LOCKESYNTAX ERRONO BUFFERS AVAILABLFILE TYPE MISMATCPROGRAM TOO LARGNOT DIRECT COMMANč$3>L[dmx- (   Ϡ734@~3!+,W,o,*--,,9,-.-~3~3,,,,~3~3,,,,~3_*3 j.5 *H*H`Lc3 (+L3 +55555 1^3_* )3J Q*L_3Ls3443 D23455545554 70 / 7 :/354545455454555535L^/5-5I5555 55` / 4/ 2-5! / 08555454 70L3 (+50+5B5C3 2 70L35 *H*H`Lg3L{3505 *H*H` 3 ,5L3 3 1 ,H 1hBL, 0 BH [1 1h`Lo3 35 ,L3 3 1B , 1L,H 0hB@ 55 [1L133 (+34) 34 70L3 3L3 (+ 055L- (+34L{33454445 70 ^/* / 3B0 HȱBh -355 -8 /L38 25` +5 /3 /. /. 3 E7D B. /. /. 0]34S0J4 4) 3 4D4E B. 4  /. 02L3 Ν3 3`HD٤33DEEhiHLG.h ` /5B5-` /5B-` + X05I33383 33DH /4 E03744Ȍ7 X040 7 J7L35B5C`,5p` / R0-55`50` K/ R0-55`575755` 4/ K/ /( 55L/BȱBL/58` D2BH5BH :/ 75Bȭ5Bhh55 R0B5m55ȱB5m55` /LR0557755`*7*75LR0 E0(33 48`433 R0` E033LR0*7*7`777 555I7575757577** 7757`7 L35555f /55555555 ^/`855 i /B58` 41L 15ȱB5 /5555 /5`3 D23ȑB55B5 / 7 55`5555555555 5555`555`55BC55`5555`L3 /5B5C355 0Q340"B4 3` 02۰Ϭ33B438`3i#`3ЗLw35!50>5555`53 /3m3 3 3733i35 3583 /35ЉLw35`H /5h 25L/~43 533`55555555J5m55m5jn5n5n5ۭ55m5555m55m55`"L? 585H ~.(3` # d ֠z# u*`JI-RES)5uBOX,42,182,236,1913:u(1):SPACE::HyCL$:RNH,"MENU" 0program visually demonstrates the","operation of five sorting routines.","The program displays the numbers as","dots on the screen, and moves the dots"à "as the numbers are moved in the array.","","",""program displays the numbers as","dots on the screen, and moves the dots"à "as the numbers are moved in the array.","","",""oves the dots"à "as the numbers are moved in the array.","","","" Sorting Demonstrations","VISUAL SORTING","This methods. During the","sorts, the number of comparisons and"u}Ã"swaps made will be displayed and","updated.","",""IÃ"Visual Sorting Demonstrations","VISUAL SORTING","This program visually demonstrates the","operation of five sorting routines.","The operation.","Four sorting methods are demonstrated:"|sÃ"Bubble Sort, Selection Sort,","Shell Sort, and Quicksort.","",""<xÃ"Sort Comparisons","SORT COMPARISON","This program is designed to allow","students to test the performance of","seven sorting ng methods are demonstrated:","Brute Force Sort, Bubble Sort,","Insertion Sort, and Selection Sort."5nÃ"Individual Student Demonstrations","INDIVIDUAL DEMO","These programs use normal-sized","characters and are most suited to","individual or small-groupm Demonstrations","CLASSROOM DEMO","These programs are designed to be used","as an *","electronic chalkboard*"," in front","of the classroom. Large characters"dià "are used to enable them to be seen in","a classroom demonstration setting.","Four sortiPACE BAR ROUTINE!:u:SPACE::+y1200FSTANDARD YES-NO INPUT\(1);:GCP,ZX,ZYCO,ZX,ZY:INP,(3,"YESNO",1),Z$:Z$(Z$,1):Z$"Y"Z$"N"36020Pò USER DATA AREAZÃ"Exploring","Sorting Routines","Version 1.1",4dÃ"ClassrooZN);:16040hBESC ESC SCREEN*iBVSP,4NrBCL$"Use of ESC Key"CC$::::|B"You may want to quit in the middle of a program. If so, press the ESC (escape) key twice whenever the computer is waiting for you to type."~BVSP,1B30000:0uSZN24(ZN49ZN48TN)16040N>ZN8ZC0ZCZC1:(8);:ZC0Z$(Z$,ZC)j>ZC0ZN8Z$"":16040z>ZN816040>ZN27ZEZE1:ZE16030,31000>ZN13ı>ZN24ZC0:Z$"":16035>ZC016040>Z$Z$(ZN):ZN32ı >ZCZC1:(S$(I,J):CTCT1":J::I:300001:WIND:CL$<:12000K:EEİ17000Q:d>INPUT ROUTINE>EXIT: ANSWER PLACED IN Z$>(1);:ZE0:16368,0:ZC0:GCP,ZX,ZY:Z$"">CO,ZX,ZY:CEL>A$:A$""16040>ZN(A$)>ZN1ZN8ZN13000:CL$+6CS(P(P(999))1)16:SLOT #?6CS1CS7CS6I6CS:]:DESCRIPTIONS :CL$DN$CC$:D2$CC$:DV$CC$:WIND,0,36:CO:CT0:I1N:CT13DLİ30000::CO:CEW:CT1:MN$(I)::CTCT2:J1DL:DS$(I,J)""DS$(I,J)" "ĺ" "Dential damages resulting from the use or operation of this software."dv/WIND:VSP,1:30000:CL$:2DECIDE UPON SCREEN FORMAT2PD(PRDRSO):TNPDN23N1SP$"s"36END OPTION6CL$:CO,0,89:"Insert another diskette."(3)630tity with respect to any liability, loss, or damage caused or alleged to be caused ";l/"directly or indirectly by this software, including but not limited to any interruption of service, loss of business, or anticipatory profits or ";Eq/" or consequ:"3490 Lexington Avenue North":9:"St. Paul, Minnesota 55112":9:"(612) 481-3527"e/30000:CL$pN/DIıX/2:17:"NOTICE:"::WIND,28,40:COUb/VSP:"NOTICE: MECC shall have no liability or responsibility to purchaser or any other person or enmHihʍiii LiL 7k 8kM9k7k !g<>=M9k?'<>7k7k8k` H g Rh PQ`L     խ)?` ` @)`,` Wj`i-ii i !g&'i jQ&-iQ&& i ii`*U U*ժ Kj')JMKj)i Q&,iP 0=Pj`Lj`J&)` `L3f̙zj{j ߅$0Hzj{j LbLvjj j` h i i i hȥq8)h` g R  QP (`L h`L)  @ iiiijii i i giiiii giiiiiB i !g&'i jQ&-iQ&&ȭii j& jQ&-iQ&& i iiay, it places the largest number in a new array and crosses out the number in the original list. ";2"This continues until there are no more numbers in the original list. The newly created list will now be sorted."<30000:xCL$:SR$"BUBBLE SE FORCE SORT":2:"THE "SR$CC$:"This sorting method is easy to understand. The program starts at the beginning of the array (the list of numbers to be sorted) and begins searching for the largest number. ";d("When it gets to the end of the arr2. BUBBLE SORT":3CO,42:"3. INSERTION SORT":UCO,42:"4. SELECTION SORT":$CO,42:"5. Return to main menu"::WIND:L18:1:"Which number? ";:INP,(1,"-15"),A$`AM(A$)AM1300,1400,1500,1600,310402000CL$:SR$"BRUTrge characters so that it can be used with the entire class.":30000JSWIND:PARSE:CL$:8:"CLASSROOM DEMONSTRATIONS":"You can choose one of the following":"options:":WIND,63,0,279,191CO,42,63:"1. BRUTE FORCE SORT":CO,42:"process of sorting the list of integers. ";x :"It is possible to exit the sort while it is working by pressing E.": D"Another menu selection will produce a listing of the sort routine in the BASIC computer language. ";DN"This listing is in laay find it helpful to freeze the display by pressing the SPACE BAR. Students should be able to explain the process after watching for a few minutes.":30000, 04:" "CA$:CEW:"A menu selection allows the computer to describe each step it takes in the e the number of items that can be sorted."F 30000:4:" "CA$:CEW "Each of the sorts presented has its own menu. You can elect to see the computer sort twelve random integers, or you may choose your own integers. "; &"During the sort, you methods of sorting with the aid of large text animation. "; "The characters and numbers that are used in these programs were designed to be easily seen by all students in an average-sized classroom.":* "This method of presentation limits to twelv30+ FKBD16384:CLR16368:MD0:T0:N12\ PHC14:CC$(3):CL$(12):CN$(14):CO$(15)e Z500q _31000{ c1000 INTRO WIND:CL$;:"CLASSROOM DEMONSTRATIONS"CC$::"Description"CC$:; "This selection of programs demonstrates four m6+ PROGRAM:CLASSROOM DEMO@PROGRAMMER: CHARLES ERICKSON ZCOPYRIGHT 1984, MECCy(LAST UPDATE: 84/09/05 BEI2163847DFT,1,29696:AFT,1<A(24),B(12):MOD(X)((X6(X6))6.05)AXP(X)MOD(X1)63 CYP(X)((X1)6)30    !   ? ";:36000:Z$"Y"ĹSB,(SB)$*+;.SUPPORT BOOK INFO.4:"A manual to aid in the use of this"::"diskette is available from MECC.".9:" Title: ";DN$:D2$""Ė13:D2$/12:" Direct inquiries to:"U/:9:"MECC Distribution":9SC ESC,MH=MENU HORIZONTAL,TC=TWO COLUMNS,SB=SOUND BYTE^.'CA$(1):CL$(12):CC$(3):D$(4)o3'PARSE:WINDu8'*SOUND SWITCH+CL$"Sound Switch"CC$ +CO,0,82:"Would you like to turn the":"sound ";:(SB)ĺ"off";+(SB)ĺ"on"; +"Z1$"...":RNH,Z$"'SUBROUTINES='P(S)(S)(S1)256|':DL8:CA0:DR0:PR0:SO0:IN1:DI0:EE1:MH1:TC0:SB9756$'DL=DESCRIPTION LINES,CA=TEACHER OPTION,DR=DISKETTE SUPPORT,PR=PRINTER SUPPORT,SOUND SWITCH,IN=INSTRUCTIONAL,DI=DISCLAIMER,EE=ERZ$X2$(0):Z1$X2$(1):4000= SOAN2PRDRİ11000:3090X AN2PDİ14000:3090p  AN1İ15000:3090 A0ANZ$CN$(A):Z1$MN$(A):4000  3020  RUN THE PROGRAMCL$:CO,0,89:"Getting "CA$;:GCP,ZX,ZY:WIND,ZX,ZY,279,191:h" ROFMH:N2PD". End":1 \:GCP,IX,IY:O RESPOND TO USER'S CHOICE CO,IX,IY:MH:"Which number? ";:CEL:16000:A$Z$ CAA$(1)Z$"TEACHER OPTIONS":Z1$Z$:4000 A((A$)) PRAN2Z$X1$(0):Z1$X1$(1):4000 DRAN2POF2((N1)9)6 OFMH:N1". General Information" 4PRĖMHOF:X1$(1)"PRINTER SUPPORT":X1$(0)"Printer Support":N2". "X1$(0) >DRĖMHOF:X2$(1)"DRIVE SUPPORT":X2$(0)"Diskette Support":N2PR". "X2$(0) HSOĖMHOF:N2PRDR". Sound Switc1210 DISPLAY MENU% CL$DN$CC$: D2$""ĺD2$CC$X 5:MH:"Program"SP$":": GCP,ZX,ZY:L1(N(TC1).5):2MH(L9):L". "MN$(L)::GCP,Z1,Z2: TCįCO,ZX,ZY:LLN:20MH(L9):L". "MN$(L)::CO,Z1,Z2: :MH:"Options:": he menu...":RNH,"MENU"3 STANDARD YES-NO INPUTI(1);:GCP,ZX,ZYCO,ZX,ZY:INP,(3,"YESNO",1),Z$:Z$(Z$,1):Z$"Y"Z$"N"36020 STANDARD RANGED NUMERIC INPUT (HI-RES) ZB = MIN, ZT = MAX, ZC = C/R LEGAL (BOOLEAN) (1);0,157:"COMPLETED"CC$:30000:H0u STANDARD SPACE BAR ROUTINE )HI-RES)]:u(1):SPACE::y STANDARD ENDING ROUTINE (HI-RES)"yWIND:(12);(15):CO,0,89:"Do you want to try again? "(1);,y360006yZ$"Y"Ĭ@y(12):CO,0,89:"Getting t00:CO,0,157:"COMPLETED"CC$:30000:3RHEAPSORTB R15000:COR"Dots form a roughly diagonal group from the lower left to the upper right.":R"Dots form a diagonal line beginning on the lower right.":XRWIND:CO,0,147:SR$(5)CC$:800:CO,:30000: NQUICKSORT'%N15000:COb*N"Dots moving in groups to a roughly diagonal area.":4N"Repeated passes move groups closer to the diagonal.":>N"A diagonal line formed, beginning with the top group.":%pNWIND:CO,0,147:SR$(4)CC$:5:8JSHELL SORT!=J15000:COmBJ"The dots are repeatedly being formed into a roughly diagonal area.":LJ"The dots are finally formed into the diagonal line, beginning from the top.": JWIND:CO,0,147:SR$(3)CC$:400:CO,0,157:"COMPLETED"CC$NSERTION SORTUF15000:CORZF"A diagonal line forming along the left side.":dF"Dots disappearing from the area on the right.":nF"The line reforming as dots are inserted.":FWIND:CO,0,147:SR$(2)CC$:700:CO,0,157:"COMPLETED"CC$:30000ine of dots forms and moves upward from the lower left.":}|B"Dots moving down this line begin to form a diagonal line.":B"Remaining dots merge into the growing line.":BWIND:CO,0,147:SR$(1)CC$:200:CO,0,157:"COMPLETED"CC$:30000: PFIRandomized array.":30000R:CO,0,118:CEW:WIND,0,118,106,191:CO:"Sorting"CC$|:5:115,0277,0277,106115,106115,0:WIND,119,4,272,104:>DO ALL FIVE SORTS>17000:18000:19000:20000:21000:hBBUBBLE SORTmB15000:CO:rB"A lCREEN VDN$,D2$,DV$,N7 `MN$(N1),CN$(N),DS$(N,DL)e jL1N:MN$(L),CN$(L):L11DL:DS$(L,L1) m(DS$(L,L1),1)"*"ćZ$:DS$(L,L1)(DS$(L,L1),(DS$(L,L1))1)(34)Z$:1133 o: t13000 BE A HELLO PROGRAM PARSE:WIND:2000:3000: PROGRAM:MENU2PROGRAMMER:SHANE MCCARRONLCOPYRIGHT:MECC, 1983k(LAST UPDATE: 84/04/24 BEI2OPTION FLAGS ARE AT 10010<PROGRAM DATA STARTS AT 50000MAIN PROGRAM10000:INITIALIZATION LREAD IN DESCRIPTIONS AND FORMAT S      LD AND RANDOMIZE THE ARRAY-:16368,0:EF0`:CL$:6:0,0106,0106,1060,1060,0:CO,0,118:"Building a 100 element array.":N10SZ:A(N1)N1:150::CO,0,118:CEW:"Randomizing the order.":N10SZ:N2((1)100):100::CO,0,118:CEW:"outine moves the randomly arranged dots, as the integers are sorted, and begins placing them in a diagonal line."; +" The sort ends when all of the integers have been sorted and all of the dots are arranged in the straight line."*+30000::BUI$:"VISUAL SORTING DEMONSTRATIONS"CC$: +"This program visually demonstrates the operation of five sorting routines. The program randomizes the integers from 1 to 100, and displays them as a random array of high resolution dots.":r+"The sorting r ެLUj,Hl  l  hl`L, HHHHHHHHH k l |jlNO,ɍɠ ɛ8nl,lPݩ mhhhhhh000`0x |||| ||x|8l````|| x````8p`````lxx|| |x ````l8|x0x0x| x0`0````0``0``v0`x000||0xxx||````` xxxxlxx x000000xx0x0xx0000 0``0 0xth`lllll~~~0` pvv0`0``0`000`~<~0000`` 0`xx0p0000xx 8` 8 x8x x<`x 0```xxxx| ```0``0`0CB$(2):CC$(3):CE$(5):CF$(6):CL$(12):CN$(14):CO$(15):CP$(16):CQ$(17)$'A(99),SR$(5),STK(1,20):L15:SR$(L):: "BUBBLE SORT","INSERTION SORT","SHELL SORT","QUICKSORT","HEAPSORT".'SZ99:KBD16384j'*STARTING SCREEN'+CLP Pxp @ @  @  @hPPP؈P PP  @@  P@ pxxxxxxpx0H@@@@pxp ` p0`` pبppxxxp@@@@H0hP @@ppppx @ @@ @  @p px Pppxxp ppبȨppph𠐈ppp pP PAUSCWININj]mjmfj9k\kkkkkkkdkklmGmmmn` PPPPPPPP xp(  @@@h @ @@  p p @  @pȈp ` pp0@0p0Pp8@p @pʝo) ,po9qp Ю 9pLo ` ֩PyQ AL ,pqpBp`$p#p p#p$p` ~LpH)hJJJBp`LANCS AZ09!/:@[`{~ @BOHOOUNHOOCECRDFAFPARSNOJUSJUSCNNOCNGCDVSHSSPACCE̢Rp RpSp[p\p߹[p\pNo pNo , g >p ,Mo %pNp) Op PpQp)@p ߅ l Ro ) L{o HHH?p hhh ɛ Moo0LooɈ5ɍ>p7,@p ? h5880`L >p?p@pMoBp ( %pL&o | {$0! ?p ,Ln ^ {$0LnNMo Qo|Oo nr- p nPo n p-PoPoPo pLsnOoQoOo^`NMo hhh,lp` ֩PyQ ALŠҠ僁 i imiʈii &' iq&iLi N8`f `.f`}m~m ` ң Σ  h`+ hR(" 0,279,191::"1. ALL FIVE SORTS":L15:L1". "SR$(L)::"7. Return to main menu":WIND:CO,0:"Which number? "CA$;:INP,(1,"-17"),A$:SR(A$):SR731040$SR16000,17000,18000,19000,20000,21000.1010'INITIALIZATIONU'16384:CA$(1):p(JR)(A(J)A(J1))JJ1?zXA(J)A(I)X:N1I:150:fA(I)A(J):N1I:150:IJ:JI2:870q MAINPARSE:WIND:11000WIND:CL$:"VISUAL SORTING DEMONSTRATIONS"CC$:"You can choose one of the following options:"TWIND,35,:JJ1:J0720. A(J1)N:N1J1:150:L:?  HEAP SORTT *L(SZ2)1:RSZm 4L0LL1:850:820 >R0XA(0):A(0)A(R):A(R)X:N1R:150:RR1:850:830 H R SIFT (USED BY HEAP SORT) \IL:J2I:XA(I)fJRA(I)X:N1I:150:&A(I)XII1:550+ 0XA(J)JJ1:560P :IJN1I:N2J:100:II1:JJ1 DF2(IJ):F2:IRSS1:STK%(0,S)I:STK%(1,S)R NRJ:F1(LR):F1:FLAG(S0):FLAG:  INSERTION SORT L1SZ:NA(L):JL1 NA(J)A(J1)A(J):N1J1:1509))1)16:T(953)10050? .'(953)(956)Ĺ953,T:956,T:FL1O 8'953,T:FL1w B'T(P(P(999))14):T(955)10080 L'(955)(958)Ĺ955,T:958,T:FL1 V'955,T:FL1 `'FL1ĺD$"BSAVEDRIVE OPTIONS,A953,L6" j'0uSTANDARD SPACE BAR ROUTINE (H,279,159:WIND,20,112,279,159:CO,20,112F/fRT:T0:R7280,7320,7340l/p"IS ";(A(J));" > ";(A(K1));"?"/zA(J)A(K1)ĺ"NO, SO MOVE ON.":7310/"YES, IT IS."/WIND:/A(K1)" IS THE MAXIMUM SO FAR."/WIND:0"PUT "A(K1)" INTO POS"a ::12:"EXPLORING SORTING ROUTINES NEEDS AT"::"LEAST 48K TO RUN.":16384,128:16368,0| P(X)(X)(X1)256  (P(P(999))1)16: 'HANDLE DRIVE INITIALIZATION 'P(S)(S)(S1)256 'D$"BLOADDRIVE OPTIONS" $'T(P(P(99tines is based on programs originally developed as an aid for high school programming classes at the Angle Park Computing Center, Adelaide, South Australia."CO$  L1LD:LL((16384)128)LD: CE$CA$:16368,0 30000 CL$:RNH,"MENU1:DFT,2,F2n PARSE:WIND:AFT,2:CA$(1):CB$(2):CC$(3):CE$(5):CF$(6):CL$(12):CN$(14):CO$(15) $BOX,0,0,279,191,1:BOX,9,10,271,181,3:BOX,18,42,261,139,6:BOX,25,50,254,130,7 .WIND,35,59,244,130:CO: CN$"Exploring Sorting RouLD300:DS0:LOGO DELAY,DISKETTE SUPPORT: MAIN PROGRAMH 16368,0d :230,32:D$"BRUNLOGO"s DSİ10000 D$"BRUNYUTIL.OBJ" 230,64:RNH,"HPRINT.OBJ":16300,0 F129696:RFL,"TITLE.FNT"F1:F2F11180:RFL,"ASCII BOLD.PFT"F2:DFT,1,FJ PROGRAM:HELLO6PROGRAMMER:SHANE P. MCCARRONPCOPYRIGHT:MECC, 1983o(LAST UPDATE: 84/04/23 BEI2ADDED NOTICE SCREENdINITIALIZATIONe::i(65435)6ĺ(4)"PR#0":(4)"IN#0":16372,0:j(978)1573000nD$(4)( x  ``wBfgC{9{{ J*B MBlLC8W0W8JUBBgBlgClk {|J*BBC AC~~|~~JUN(2L)$ FLAG01:L10SZSPANW A(L1)A(L1SPAN)FLAG0:N1L1:N2L1SPAN:100e L1:FLAGn L:  QUICK SORT S0:STK%(0,S)0:STK%(1,S)SZ FLAG01:LSTK%(0,S):RSTK%(1,S):SS1 F101:IL:JR:XA(((LR)2)) F201 0) (KBD)197(KBD)229Č54915:1010Q (KBD)127EF(KBD)155:16368,0| 4:N13,3N13,103:7:N13,A(N1)3: BUBBLE SORT LSZ11:L10L1 A(L1)A(L11)N1L1:N2L11:100 L1:L:  SHELL SORT L401:SPA155EFČ54915:1010< s(KBD)197(KBD)229Č54915:1010d t(KBD)127EF(KBD)155:16368,0 xZA(N1):A(N1)A(N2):A(N2)Z 7:N13,A(N1)3:N23,A(N2)3 PLOT THE POINT N1=INDEX TO ARRAY ELEMENT (KBD)155EFČ54915:101 PROGRAM:VISUAL SORTING<PROGRAMMER: BRET INDRELEEWCOPYRIGHT: MECC, 1984w( LAST UPDATE: 84/07/16 BEI210000<31000c1000dSWAP AND PLOTe N1,N2 INDEX OF ELEMENTS TO SWAPn4:N13,A(N1)3:N23,A(N2)3 q(KBD)53@yCL$:CO,0,89:"Getting the menu...":RNH,"MENU"ENU"NU"g the menu program...":RNH,"MENU".":RNH,"MENU"310,72402P(KBD)12820510A2(PCLR,0:K(KBD):EFK2731000]22PEFK27:K69K101ġ:2NEFK27:K69K101ġ:1HNK32ı2PMD1ĴAM4280,5290,6ITION."0WIND:)0 DISPLAY INTRO H0CN$:X112:7180:X:CO$0WIND,20,88:CO,20,88:A12ĺ"THE TWELVE NUMBERS SHOWN ABOVE ARE IN RANDOM ORDER. WE WILL USE A "SR$" TO PUT THEM IN ORDER FROM SMALLEST TO LARGEST."1CO,20,142:MDĺ"Press          (z"#~  ԳԠ ԴԠ ԮԠ ҮŮ  Բ Գ Դ ԠŠ ͠Ϡ*̮ʠԲԠ  ̠ϠԮʠϠ  ͠Ϡ- ŮԠԠΠ  Р  ՠ̠Ϡ ЮԠ  ҮŮ!ҠĠϠՠ̠Ӡ ϠɠĮԠР ŠӠ ԠΠ̠Ǡ the entire list is sorted.")30000:XCL$:SR$"INSERTION SORT":2:"THE "SR$CC$:"This sort begins by moving up through the list one item at a time. It then scans down from this item, looking for a number that is less than the top item. ";ORT":2:"THE "SR$CC$:"This common sort is used mainly for very small lists of items. The method is to scan the list and";" swap any adjacent items that are out of order, so that larger items move toward the top. This process continues untilmber.":oT"When it gets to the top of the list, it swaps the number there with the largest number found.":^"The top of the list is moved down one to protect the newly placed number, and the process continues."h30000: SELECTION MENU,h"If the number being tested is not less, it is moved up one space in the list to make room below."u30000:@CL$:SR$"SELECTION SORT":2:"THE "SR$CC$J:"This sort begins by scanning from the start of the list, looking for the largest nu,42:"4. LIST THE SORT ROUTINE":Z%CO,42:"5. Return to CLASSROOM DEMONSTRATIONS menu"*WIND:CO,0,160:"Which number? ";:INP,(1,"-15"),A1$:A1(A1$):MD0/A15ī10004A1((A1$)):A12200,2300,2400,2500>A14ī2000H3000X1CL$:"SORTING DEMONSTRATION"CC$:SR$;CC$y5:"You can choose one of the following":"options:":WIND,63,0,279,191CO,42,64:"1. SORT 12 RANDOM NUMBERS": CO,42:"2. ENTER YOUR OWN NUMBERS":CO,42:"3. SEE THE SORT PROCESS":! COcontinues, until the step size is 1.":300003::CEW:"The choice of steps is important for efficient operation. Typical values in moderate-sized lists may be 10, 8, 5, 3, and 1, but in larger lists of several thousand items, the steps";" may CC$^:"The ";SR$;" method of sorting is based on a series of step sizes. During a pass";," through the list, items that are a "QU$"step"QU$" apart are compared and exchanged if out of order. The size of the step is then reduced and the process t gets to the top of the list, it swaps the number found there with the largest number found.":"The top of the list is moved down one to protect the newly placed number and the process continues."30000:CL$:SR$"SHELL SORT":2:"THE "SR$larger items move toward the top. This process continues until the entire list is sorted."h<30000:xCL$:SR$"SELECTION SORT":2:"THE "SR$CC$`:"The sort begins scanning from the start of the list, looking for the largest number."::"When iA1300,1400,1500,1600,8000(2000TCL$:SR$"BUBBLE SORT":2:"THE "SR$CC$:"This common sort is used mainly for very small lists of items. The method is to scan the list and";[(" swap any adjacent items that are out of order, so that se one of the following":"options:":7D" 1. BUBBLE SORT":d" 2. SELECTION SORT":" 3. SHELL SORT":" 4. QUICKSORT":$" 5. Return to main menu"::L18:1:"Which number? ";:INP,(1,"-15"),A$`A(A$)CLR,0:SS(KBD)32:(KBD)27EF31000S(KBD)69(KBD)10131000: IF E HITmEF(KBD)27:SS455CO,0,183:CEW:"Press SPACE BAR to stop"CC$:EF0:SS0:3:WIND:PARSE:CL$:"INDIVIDUAL STUDENT DEMONSTRATIONS"CC$:'"You can chooTOP ROUTINE$  SS=START/STOP FLAG1 SS450C (KBD)128ıb CLR,0:(KBD)27EF31000s EF(KBD)27 (KBD)69(KBD)10131000:IF E HIT (KBD)32ı CLR,0:CO,0,183:CEW:"Press SPACE BAR to start"CC$ (KBD)128455(OCATIONS IN A(N) TO SWAP4 . SW = # OF SWAPS MADEY 6SWSW1:CO,LX168,LY:ZNSW:150q ;2:Z1N1:Z2N2:250 @ZNA(N2):CO,X(N1),Y(N1):100 JZNA(N1):CO,X(N2),Y(N2):100 O0:PAUSE,7:250 TA(N1)A(N2):A(N2)ZN:  SPACE TO START/S00: IF E HIT & BOX 2 DIGITF Z1,Z2 = LOCATIONS TO BOX ZXX(Z1)3:ZYY(Z1)2:280:ZXX(Z2)3:ZYY(Z2)2:280:  BOX  ZX,ZY = UL CORNER "ZX,ZYZX18,ZYZX18,ZY10ZX,ZY10ZX,ZY: , SWAP VALUES - N1,N2 = L ZN = NUMBER TO PRINT2 (" "(ZN),4):J COMPARISON COUNTj CP = # COMPARISIONS MADE CO,LX56,LY:CPCP1:ZNCP:150 (KBD)128ı (KBD)160ı CLR,0:(KBD)27EF31000 EF(KBD)27 (KBD)69(KBD)1013106368e PCC$(3):CL$(12):CN$(14):CO$(15):XC25:YC15:H14:W22:LX42:LYYC(10.2H):QU$(34) UX(L)XCWMOD(L):Y(L)YCH(L10) c1000 d TWO DIGIT PRINT e ZN = NUMBER TO PRINT nZN10ĺ" "; xZN: FOUR DIGIT PRINT3 PROGRAM:INDIVIDUAL DEMOAPROGRAMMER: BRET INDRELEE [COPYRIGHT 1984, MECCz(LAST UPDATE: 84/09/05 BEI2163847DFT,1,29696:AFT,1<A(99),STK(1,49):MOD(X)((X10(X10))10.05)ARA(N)((1)N) FKBD16384:CLR1              $:30000P  BUBBLE SORTv CL$;CN$:"10 FOR I=0 TO N-1":"20 FOR J=0 TO N-I":"30 IF A(J) <= A(J+1) THEN 70" "40 K=A(J)":"50 A(J)=A(J+1)":"60 A(J+1)=K":"70 NEXT J":"80 NEXT I":CO$:30000  INSERTIONI CL$;CN$:"10 FOR I=1 TO MD1:2200  DISPLAY LISTING< AM2600,2700,2800,2900B S( BRUTE FORCE2 CL$;CN$:"10 FOR I=N TO 0 STEP -1":"20 K1=0":"30 FOR J=1 TO N"< "40 IF A(J) > A(K1) THEN K1=J":"50 NEXT J":"60 B(I)=A(K1)":"70 A(K1)= -1"F "80 NEXT I":CO12:A(X)((1)99)1::'CL$:2:1o "PLEASE ENTER YOUR 12 NUMBERS. THEY MUST BE IN THE RANGE 0 TO 99." ::I112 I5:1:"NUMBER "; 8(I10):I;" = ";:CEL$ INP,(2,N),A$:A((A$))8 A(I)A:B ` SHOW HOW IT WORKS jO,XC10W1,LYH:"Stack"n!w1:XC10W4,YC2XC10W4,LY2XC10W34,LY2XC10W34,YC2XC10W4,YC2!z400:S0:STK(0,S)0:STK(1,S)SZ!FLAG01:LSTK(0,S):RSTK(1,S):SS1#"F101:IL:JR:XA(((LR)2)):CO,LX189,LYH:ZNX:100:SWSWCO,LX119,LYH:ZNL1:100:CO,LX189,LYH:ZNA(L1):100y F91:200:A(L1)A(L1SPAN)N1L1:N2L1SPAN:300:FLAG0:F90 400:F9įPAUSE,7:0:250 L1:FLAG L: p QUICK SORT!uCO,LX,LYH:"Left = 0 Right = 99 Mid = ";:ZNA(49):100:C:N2SZL:3006ZXX(N1)3:ZYY(N1)2:0:280:L:H SHELL SORT~CO,LX,LYH:"Step = 0 J = 0 A(J) = 0":400L401:SPAN(2L):CO,LX49,LYH:ZNSPAN:100:SPANSZ15060FLAG01:L10SZSPAN7 Z1L1:Z2L1SPAN:2:250:X42,LYH:ZNSZL:100:L10SZLXZXX(L1)3:ZYY(L1)2:2:280:PAUSE,7:400:200mA(L1)MAX4025MAXA(L1):ZXX(N1)3:ZYY(N1)2:0:280:N1L1:CO,LX133,LYH:ZNMAX:100:400:4030400:L10ZXX(L1)3:ZYY(L1)2:0:280 L1200:400:A(L1)A(L11)N1L1:N2L11:3006 0:250C L1:L:X SELECTION SORTCO,LX,LYH:"Top = ";:ZNSZ:100:CO,LX63,LYH:"Maximum = 0"400:2:ZXLX130:ZYLYH2:280!L0SZ1:N10:MAXA(0):CO,LX133,LYH:ZNMAX:100:CO,LINP,(3,N),A$-SZ(A$)1:SZ4SZ992040l L0SZ:A(L)RA(100):L:7000:A3000,4000,5000,6000,8000CA$:CO,0,LYH2:CEW:20:SR$" finished."CC$ 30000:1000 BUBBLE SORT 400:LSZ11:L10L1 Z1L1:Z2L11:2:250* :"This program will sort up to 100 positive integers in ascending order using the "SR$" method.":GCP,ZX,ZY:CO,0,151:"To return to the menu during the sort, press E to exit." CO,0,ZY:"How many numbers do you want to":"sort (5-100)? "CA$;:U$"sub-list"QU$;|" it is sorting gets to two items and these are placed in order. The sort terminates when there are no more top or bottom values on the stack."30000: SELECT LIST SIZECL$:"SORTING DEMONSTRATION"CC$::SR$CC$b: knows what parts are left to be sorted.":r"When the lower section is sorted, the same procedure applies. The sort finds the next piece to be sorted by "QU$"popping"QU$" new top and bottom values from the stack. It does this when the size of the "Qe value of the middle value and that all items above it are greater."Zh30000:3::CEW+m"Then the lower portion of the list is treated in the same way. The start and end points of the top half of the list are saved on the stack so that the programd in this case uses a "QU$"stack."QU$::"The sort works in the following way.":^"An item near the middle of the list is chosen. A process of swapping then occurs to ensure that all items in the list before";Ec" this middle mark are less than th probably one of the fastest sorting methods available. The sort is suited to recursion techniques and is often presented in books on languages (such as PASCAL) that allow recursion.";QT" As most versions of BASIC do not allow recursion, the sort useneed to be greater. The efficiency of this method is due to exchanges occurring across moderately large gaps, thereby placing items closer to their final position in fewer steps."30000:@CL$:SR$"QUICKSORT":2:"THE "SR$CC$J:"The "SR$" is"A(J)A(J1)51305"KA(J):A(J)A(J1):A(J1)K"AJ:BJ1:CO,(XP(A))74,YP(A)14:CO$"SWAP"CN$:CO,XP(B)74,YP(B)14:CO$"SWAP"CN$"T2:20000"XJ:5180:XJ1:5180" AJ:5240:AJ1:5240":#WIND:BOX,0,138:CO$:30000:MDĺ"Press RETURN to start.":k!CO,112,127:"Press SPACE BAR to single step."::"Press E to exit."|!WIND:21000!CL$:SR$;CC$:!5430:CN$! MAIN LOOP!I1N1!CLR,0!J1NI!AJ:5210:AJ1:5210!T1:20000(A(X)),2):X:CO$5 b3:100,0100,178101,178101,0Y gWIND,102,0,279,191::SR$CC$: lWIND,112,30,279,191::"THIS SIMPLE SORT FINDS":"THE MAXIMUM NUMBER AND" "PLACES IT IN ANOTHER":"LIST. THE NUMBER IS":"THEN CROSSED OUT.":CO,112,100"!YES IT IS.":"MAKE ";(A(J)):"MAXIMUM."8WIND:T0:L"END OF LIST."k"MAXIMUM WAS "(A(K1))".""PUT ";(A(K1));" IN THE"&"OTHER LIST."0"MARK OFF "(A(K1))".":WIND:T0:D DISPLAY INTRO  XCN$:1:1:X112:(" "K1)),2),I 6CO$:30000:/TEST A(A)SCO$:CO,20,(AHC14):A$:CN$Yt DISPLAY AND EXPLAINT0ıWIND,112,26,279,120:BOX:CO,112,40T24360"IS "A(J)" > "A(K1)"?"A(J)A(K1)ĺ"NO. MOVE ON.":4350("1:4250J2N*AJ:A$"TEST":4250MT1:20000:A$" ":AJ:4250A(J)A(K1)A$" ":AK1:4250:A$"MAX.":AJ:4250:K1JJB(I)A(K1):T2:20000:A$" ":AK1:4250I:7:(" "(B(I)),2)A(K1)1"K1:(" "(A() THEN K1=J"hh "50 NEXT J":"60 K2=A(K1)":"70 A(K1)=A(N-I)":"80 A(N-I)=K2":"90 NEXT I":CO$:30000nr  PERFORM SORT WIND:BOX:EF0:AM4000,5000,6000,7000 CO$:20004420:CN$ MAIN LOOPIN11K11:A$"MAX.":AK N":"20 K1=A(I)":"30 FOR J=I-1 TO 0 STEP -1":"40 IF A(J) < K1 THEN 70" "50 A(J+1)=A(J)":"60 NEXT J":"70 A(J+1)=K1":"80 NEXT I":CO$:30000 T SELECTION ^ CL$;CN$:"10 FOR I=0 TO N-1":"20 K1=0":"30 FOR J=1 TO N-I":"40 IF A(J) > A(K1):100:L%qCP0:SW0J%vCO,LX,LY:"Tests = 0 Changes = 0"CA$:`%@ END THE PROGRAM%J(12):CO,0,89:"One moment please...":RNH,"MENU"%0u STANDARD SPACE BAR ROUTINE%:u(1):SPACE::%y54915:1000TK(0,S)I:STK(1,S)R=$RJ:F1(LR):F1:FLAG(S0):FLAG:Q$X SCREEN LAYOUT$]CL$:ZN09:CO,X(ZN),YCH:100:CO,XCW,YCHZN:100:ZN$b1:XC210,YC4XC6,YC4XC6,YC135XC7,YC135XC7,YC5XC210,YC5 %lL0SZ:CO,X(L),Y(L):ZNA(LI:100:200:400:A(I)XII1:PAUSE,7:0:280:6045#Z1I:Z2J:2:250:CO,LX126,LYH:ZNJ:100:200:400:XA(J)JJ1:PAUSE,7:0:280:6050#F9(IJ):F9N1I:N2J:300:II1:JJ1#F2(IJ):F2(F9)Ē0:Z1I:Z2J:250$F2:IRSS1:S1:CO,LX168,LY:ZNSW:150:F201y"S7įCO,XC10W1,YC(7S)H:ZNL:100:CO,XC1310W,YC(7S)H:",";:ZNR:100"S6įBOX,XC10W3,YC1,XC10W33,YC(7S)H3"F201"CO,LX126,LYH:ZNJ:1006#Z1J:Z2I:2:250:CO,LX49,LYH:ZN:GCP,ZX,ZYZL((ZT))WCO,ZX,ZY:INP,(ZL,N,(ZC)),ZN$:ZN(ZN$):ZCZN$""ıZNZBZNZTįCO,0,181:ZF1:"Enter a number between "ZB" and "ZT"."(3):37030ZFįCO,0,181:CEW:CO,ZX,ZY:Đ (hHhhh hJ` &eeieh ghIi[hi 썠h !gmhﬡhMh[hPjjjjjjj0jj) h0ȱjhjhhУ`8pPH)8 q -`,f` im imʈii iʎiLi Fggg`gg ggg`g Fg gggg`ggg8pzg.g(zgggmgg`8pg)gJJ gggg .g .g ngg)ggmgg`de80 " Ofm8h)` dem88eLf` deme` d8` f@ ~f ~f f`Lb dffL-f ``fʽ`) ` `fH`mS` dS`)\e`[e h\e g[e}`mf8ff`f` dLb,0*`%f 8fHfJhj`mfff` b d` b dI``L `emfff`) ffffffO,0 `)  d`f(`HHf,Pf88`f d fhLcfHfHff,P d fhf8hfffffff``S`S```f穀f f`f3f'ff ``)   LX8e湥 pHpH L`@ @ʩ WRPT` J  dȱȱȱ` hfH) #,f h`` fffffffh`f fS```emffff f0 d -f%%h $20 LUc $ aHaH`d\eheWeeeee,fNfgffffff(bb d #cf hf gNOH #c h f ghH ,aɈ( #cb h) e f g #c ebbh`yo 8`?```L`bbbbps$% `@ LaQa6 ,fLbLhfUabHaa,aaɠ,|a ` a欌aah`ɀ)?  @IH #c$ d e$%     3):37030,!ZFįCO,0,181:CEW:CO,ZX,ZY:2!ĐXT0ı;$BOX,0,88,279,159:WIND,20,88,259,159:CO,20,88L$T5340,5380V$T0:s$"IS "A(J)" > "A(J1)"?"$A(J)A(J1)ĺ"YES IT IS, SO SWAP.":5370$"NO, SO MOVE ON."$WIND:T0:$"SWAPPING "A(J)" AND "A(J1)"." %"NOTE THAT TH##< DISPLAY THE NUMBER IN A(X)J#FCO,(XP(X))7,YP(X):(A(X))" "P#Pb#ZTEST A(A)...#dCO$:CO,(XP(A))74,YP(A)14:"TEST";CN$#n#x CLEAR UNDER NUMBERS#CO,(XP(A))74,YP(A)14:CO$" "CN$## SHOW AND TELL!$&L`L 䎱 掲`RFRNSEٌGt `SEٌV `:p"s>t? %p ֎g^h_^`ȱ^Șe^^_iȑ^^_ihg@A c  S `@ i @ ȱ `,X` {ݩD ^ D`kDlED` Х?t 0 &֎ eL׭XLXLX ׎$)֎s>t? p֎ G 8`L8ghegiȱehj8ȱCv ȱ8쭵8ȱ>? I<<`<=ʱD>` VDkElBoCp@qAr>s?t 0  { RPQ L ֎Ll`N bDkElBoCp@qAr>sgLL㏩Ӆ 8ɀ  L8e湥 ޏHݏH L` <=<ȥ?< <<= H <=BBYCFJUNGYCD<]GOGCGA~HBBOBYOCFJ*NGYa@BO@aEff~[GO~x`FGA>B~BBBYCFJUNGVACEOAErpssprspx[GQF@``DpA`@HB@@_BY_CFJ*NGYBOjGOG|]GO~x`FDQB oBlOCFJUNGfa@OaGP?D@D`DpD8DBBBLBlOCFJ*NGVI?CAgABg]GOaHDQBBOB`OCFJUNGVAA~A`A~AEA?B]GQ|0TAA >~~B@@oBLOCFJ*NGYsccsBA|D|Ap]GOE@`ppG`@GJ*NGAGJp`@UCUBUBUUUBUABUCUBOBfFCFJUNGdC?AA?^GN~C*B*B* FBC BBB CFJ*NGc @~@@]GOCUBWBB@B`@CFJUNGfBs]GOCC@D`DpD8DBBBGlo`OCFJ*NGfB捿ttmtt`BB0xXCFJ*B037B6ACFJUBBC3ACFJ*BBC3ACFJUNA^D?A/A/++++**BB3?>CFJ*NGAGOC_B WUUUBUABUCUBB>0CFJUNGTvGLB?C*B*B***B*AB*C*BBB3CFtb u@ )` t t t0H)?hJ t t t?Lt t&'&Ȅ``tt ttt`t)tJJ tttt .t .t ntt)   :"How many numbers do you want to":"sort (10-500)? ";:ZB10:ZT500:ZC0:37000:SZZN1iCL$PN$CC$.:"There are five types of number lists available:"::WIND,42,0,279,191:CO,21:"1. A list of completely random numbers.":k8CO,21:"2. A soW1:*SWSW1:A(I)A(J):IJ:JI2:87049000TWIND:PARSE:CL$:PN$CC$:"Select the sort methods you want by typing YES or NO."L17:6L:3)L". "SR$(L):LSR0:L17:6L:23:36000:SR(L)Z$"Y":SRSRSR(L):L:SR031040Z*L(SZ2)1:RSZ,4L0LL1:850:820e>R0XA(0):A(0)A(R):A(R)X:SWSW3:RR1:850:830kHR SIFT (USED BY HEAP SORT)\IL:J2I:XA(I):SWSW1fJRA(I)X:SWSW1:p100:JRA(J)A(J1)JJ1z100:XA(J)A(I)X:SWS X BRUTE FORCE SORTH bLSZ01:N0:L11SZ:100:A(L1)A(N)NL1p lL1:SWSW1:B%(L)A(N):A(N)1:L:  INSERTION SORT L1SZ:NA(L):JL1 100:NA(J)A(J1)A(J):JJ1:SWSW1:J0720 A(J1)N:SWSW1:L:  HEAP SORTF101:IL:JR:XA(((LR)2)):SWSW12 F201N &100:A(I)XII1:550j 0100:XA(J)JJ1:560 :IJZNA(I):A(I)A(J):A(J)ZN:SWSW3:II1:JJ1 DF2(IJ):F2:IRSS1:STK%(0,S)I:STK%(1,S)R NRJ:F1(LR):F1:FLAG(S0):FLAG:(2L):SPANSZ14503 FLAG01:L10SZSPAN 100:A(L1)A(L1SPAN)FLAG0:SWSW3:ZNA(L1):A(L1)A(L1SPAN):A(L1SPAN)ZN L1:FLAG L:  QUICK SORT S0:STK%(0,S)0:STK%(1,S)SZ FLAG01:LSTK%(0,S):RSTK%(1,S):SS1& )A(L11)SWSW3:ZNA(L1):A(L1)A(L11):A(L11)ZN@ L1:L:U , SELECTION SORT| 6L0SZ1:MAXA(0):N10:L10SZL @100:A(L1)MAXMAXA(L1):N1L1 JL1:SWSW3:ZNA(N1):A(N1)A(SZL):A(SZL)ZN TL:  SHELL SORT L401:SPAN:31000( (KBD)155EFČ54915:31000A EF(KBD)155:CLR,0u 32KQ:20:ZNCP:150:32KQ:32:ZNSW:150: PRINT 6 DIGIT NUMBER ZN = NUMBER TO PRINT (" "(ZN),6): BUBBLE SORT LSZ11:L10L13 100:A(L1r PROGRAM:SORT COMPARISONAPROGRAMMER: BRET INDRELEE [COPYRIGHT 1984, MECCy(LAST UPDATE:84/09/05 BEI210000<31000c1000d COMPARISON COUNTn CP = NUMBER OF COMPARISONSxCPCP1 (KBD)197(KBD)229Č54915          ZNZTįCO,0,181:ZF1:"Enter a number between "ZB" and "ZT"."(3):37030k ZFįCO,0,181:CEW:CO,ZX,ZY:q ĐCO,0,181:CEW:CO,ZX,ZY: ĐĐY):37030 ZFįCO,0,181:CEW:CO,ZX,ZY: Đ 1:"Enter a number between "ZB" and "ZT"."(SNO",1),Z$:Z$(Z$,1):Z$"Y"Z$"N"360202_ STANDARD RANGED NUMERIC INPUT (HI-RES) ZB = MIN, ZT = MAX, ZC = C/R LEGAL (BOOLEAN)(1);:GCP,ZX,ZYZL((ZT))CO,ZX,ZY:INP,(ZL,N,(ZC)),ZN$:ZN(ZN$):ZCZN$""ıH ZNZBANDARD ENDING ROUTINE (HI-RES)a"yWIND:(12);(15):CO,0,89:"Do you want to try again? "(1);l,y36000}6yZ$"Y"1010@y(12):CO,0,89:"Getting the menu...":RNH,"MENU" STANDARD YES-NO INPUT(1);:GCP,ZX,ZY,CO,ZX,ZY:INP,(3,"YERA(1000):B%(L)(F12)RA(F1):F3F2B%(L):L1F2F3:C%(L1)A(L):L1SZĂL1:F2F31:L^6q: ORDERED LIST:L0SZ:C%(L)L:L:> REVERSE ORDERED LIST>L0SZ:C%(L)SZL:L:0u STANDARD SPACE BAR ROUTINE:u(1):SPACE::y ST* PRINT HALF SPACE 6+GCP,ZX,ZY:CO,0,ZY6:H. RANDOM LISTi.L0SZ:C%(L)RA(1000):L:2 ORDERED LIST, 5 MISPLACED2L0SZ:C%(L)L:L:L15:C%(RA(SZ1))RA(1000):L:6 RANDOMLY GROUPED LISTX6F1(N20):F20:L04:A(L)384:CLR16368CB'CC$(3):CL$(12):CN$(14):CO$(15):QU$(34)oL'X(L)XCWMOD(L):Y(L)YCH(L10)V'L17:SR$(L):L: BRUTE FORCE,BUBBLE SORT,INSERTION SORT,SELECTION SORT,SHELL SORT,HEAPSORT,QUICKSORT`'PN$"SORT COMPARISONS"j'zn#" 1. the number of comparisons made"::" 2. the number of exchanges made"::" 3. the length of time required"x#30000:'16384'DFT,1,29696:AFT,1$'A(499),B%(499),C%(499),STK%(1,90),SR(7),SR$(7).'RA(N)((1)N)8'KBD16ks best in every situation."::"Judging which method is the best for your program should be made by comparing each routine in each type of sorting situation."d#:"Using this program, you can analyze the performance of each sorting method based on:":"In this program you can choose:":WIND,28,0,279,191:K#CO,14:"- the sorts you want to compare"::CO,14:"- the number of values to be sorted"::CO,14:"- the original order of these values":WIND:P#30000Z#CL$::"No one sorting method worW:30000(31000)(#BEGINNING SCREENI2#WIND:PARSE:CL$:PN$CC$:<#"This program compares the performance of seven sort methods. This comparative analysis is made by counting the number of comparisons and exchanges made by each method.":7F#0,29109,29109,160108,160108,290,296MSİ1205bKQ17:EF0:CP0:SW0:SR(KQ)MSİ1205SR(KQ)āQK0SZ:A(QK)C%(QK):QK:KQ600,200,700,300,400,800,500 SR(KQ)Ģ3KQ2:20:ZNCP:150:3KQ2:32:ZNSW:150KQCO,0,161:19:CE"<LT3ĺ"a list of "SZ1" numbers in random groupings."jLT4ĺ"a sorted list of "SZ1" numbers."LT5ĺ"a list of "SZ1" numbers sorted in reverse order."L17:32L:SR$(L):'5:0,28279,28279,29201,29201,160200,16020lected.":30000PCL$PN$CC$::"SORT TYPE";:18:"COMPARISONS CHANGES":1260w19:"Ready to sort.";:CEW:3000019:"Sorting ";:LT1ĺ"a list of "SZ1" random numbers."LT2ĺ"a sorted list of "SZ1" numbers with five elements misplaced.INP,(1,"-12"),A$:MS(A$)1j`:"Do you want to change any of your choices? "CA$;:36000:Z$"Y"ī1010~BOX:9:"Please wait while the numbers are selected...":LT12000,13000,14000,15000,16000PAUSE,10:BOX:CO,0,89:"The numbers have been seP,(1,"-15"),A$:LT(A$)+LCO,0,18:CEW:Q"There are two modes of advancing between sorts:"::WIND,42:CO,21:"1. Manually start each sort with key press.":CO,21:"2. Each sort begins automatically."CA$:WINDV:"Which mode do you want? "CA$;:rted list with five randomly placed numbers."::CO,21:"3. A list of randomly placed groups of numbers.":=CO,21:"4. List of sorted numbers."::CO,21:"5. List of numbers in reverse order."CA$:WIND:B"Which type of list do you want? "CA$;:IN:20000 -AJ::A$" ":7210`-A(J)A(K1)AK1:7210:K1J:A$"MAX.":AK1:7210:T2:20000g-J-A$"SWAP":AK1:7210:ANI1:7210-T3:20000-K2A(K1):A(K1)A(NI1):A(NI1)K2-XK1:7180:XNI1:7180 .A$" ":AK1:7210:ANsingle step."::"Press E to exit.".,<21000J,FBOX,0,88,279,130:WINDv,PCO,20,88:"LOOKING FOR POSITION OF-->"|,Z,XCL$:SR$CC$::7360,b MAIN LOOP,lI1N1:K11,vAK1:A$"MAX.":7210,J2NI1,AJ:A$"TEST":7210-T112:6250:X:CO$+#WIND,20,88:CO,20,88:A12ĺ"THE TWELVE NUMBERS SHOWN ABOVE ARE IN RANDOM ORDER. WE WILL USE AN "SR$" TO PUT THEM IN ORDER FROM SMALLEST TO LARGEST."+-CO,20,142:MDĺ"Press RETURN to start."#,2CO,20,160:"Press SPACE BAR to 90,6400**"IS ";(K1);" < ";(A(J));"?"2*T0S*K1A(J)ĺ"YES IT IS.":6405s*"NO - GONE TOO FAR.":6405*T0:"MOVE ";(A(J));" UP ONE.":6405*T0:"PUT ";(K1);" IN THE":"NEXT POSITION."*WIND:*  DISPLAY INTRO +CN$:X1)j DISPLAY THE NUMBER IN A(X)G)tCO,(XP(X))7,YP(X):(A(X))" "M)~_)TEST A(A)...)CO$:CO,(XP(A))74,YP(A)14:A$;CN$)) DISPLAY & EXPLAIN)T0ı)BOX,0,112,279,140:WIND,20,112,279,140:BOX:CO,20,112*T6350,636280(AJ:6280(J>($AJ1:A$"MOVE":6280:A(J1)K1_(.CO$:CO,207,102:"MOVE";CN$(8T3:20000:XJ1:6250:CO,207,102:CO$;" "CN$:20000(BAJ1:A$" ":6280:AI:6280(LI(VWIND:CO,20,88:CEW:"SORT COMPLETE."CO$:30000: (K1);" "'JI1111'AI:A$" ^^ ":6280X'A$"TEST":CO$:CO,207,102:A$;CN$f'AJ:6280u'T1:20000'A(J)K1AJ:A$" ":6280:6180'AJ:A$"MOVE":6280:A(J1)A(J)'T2:20000'XJ1:6250'20000(AJ1:A$" ":R FROM SMALLEST TO LARGEST."J&YCO,20,142:MDĺ"Press RETURN to start."&^CO,20,160:"Press SPACE BAR to single step."::"Press E to exit."&hWIND:21000&pCL$:SR$CC$::6410:6470&z MAIN LOOP&CN$&I2N:K1A(I) 'CO,210,88:E LARGER"%%"NUMBER FLOATS UPWARD";%""LIKE A BUBBLE."K%,WIND:T0:a%6 DISPLAY INTRO %JCN$:X112:5180:X:CO$&TWIND,20,88:CO,20,88:A12ĺ"THE TWELVE NUMBERS SHOWN ABOVE ARE IN RANDOM ORDER. WE WILL USE A "SR$" TO PUT THEM IN ORDE@~@]GsB`B0`Ca]a}}JUNGfc]GsBgB0gC.5B;J*NGf|x|xx|]GsBsB63Cwx{JUNGAGsBs600p00CBnJ*NGAGsBcB6cCtwutJUNGAGsBsB63CCnJ*NAsBc600`CFJUOAs@NHxBByB{CFJUNGYBDCA?A C<|]GsBBqCFJ*NGYss~~xxB~`p]Gs00{C3ACFJUNGYyxyyxyyx|ggccBgA]GsvC6ACFJ*NGf'Dg]GsBcB6f`CBwJUNGfx0C3s]GsBBCFB;FJ*NGfL|HBFACFJUNGYp`Bg`pBAAsA3ss]GOD@CBGB <??E`@BO@`]GOFx~J~xHBBX}- CFJ*NGVA~D>A8EDyC]GOH LISTING; V "10 FOR L=4 TO 0 STEP -1","20 SPAN=INT(2^L)" ` "30 IF SPAN > SZ+1 THEN 90","40 FLAG=0","50 FOR L1=0 TO SZ-SPAN" j "60 IF A(L1) > A(L1+SPAN) THEN FLAG=1: TEMP=A(L1): A(L1)=A(L1+SPAN): A(L1+SPAN)=TEMP" t "70 NEXT L1","80 IF FLAG TH0 x(16384)128120 B PRINT OUT LISTINGS 1 AT A TIMEW V(Z)(Z281)q :DFT,1,29696:AFT,1 WIND,30,0,279,191 CL$CN$; A$:A$"*"ĺCO$CL$: A$"P"İ100:1020 A$""įCO,0:A$:1030 100:1020 LSHELL SORT  PROGRAM:MAKE LISTINGS;PROGRAMMER: BRET INDRELEEVCOPYRIGHT: MECC, 1984u(LAST UPDATE: 84/09/05 BEI-16384:230,64210000724576<F129696:RFL,"TITLE.FNT"F1:DFT,1,F1:AFT,1c1000d WAIT FOR KEY PRESS n16368,    !! "EN 40","90 NEXT L" ~ ""3 QUICK SORT LISTINGb "10 S=0","20 STK(S,0)=0","30 STK(S,1)=SZ"  "40 L=STK(S,0)","50 R=STK(S,1)","60 S=S-1"  "70 I=L","80 J=R","90 X=A(INT((L+R)/2))"  "100 IF A(I) < X THEN I=I+1: GOTO 100","110 IF X < A( R THEN A(I)=TEMP: RETURN"yF "110 IF J < R AND A(J) < A(J+1) THEN J=J+1","120 IF TEMP >= A(J) THEN A(I)=TEMP: RETURN"P "130 A(I)=A(J)","140 I=J","150 J=I*2","160 RETURN"Z ""(# "*"'INITIALIZATIONC'16384:CA$(1):CB$(2):CC$(3): HEAP SORT LISTINGf  "10 L=INT(SZ/2)+1","20 R=SZ","30 IF L > 0 THEN L=L-1: GOSUB 60: GOTO 30" ( "40 IF R > 0 THEN TEMP=A(0): A(0)=A(R): A(R)=TEMP: R=R-1: GOSUB 60: GOTO 40" 2 "50 END"< "60 I=L","70 J=2*I","80 TEMP=A(I)","P","90 IF J >J) THEN J=J-1: GOTO 110"e  "P","120 IF I <= J THEN TEMP=A(I): A(I)=A(J): A(J)=TEMP: I=I+1: J=J-1"  "130 IF I <= J THEN 100","140 IF I < R THEN S=S+1: STK(S,0)=I: STK(S,1)=R"  "150 R=J","160 IF L < R THEN 70","170 IF S >= 0 THEN 40"  ""003f<ffcc>cc>>cc>~t` ffffffffff~l6iɆpq{ 0 00000 0 0Z<`~~6  6yZ$"Y"ĬK@y(12):CO,0,89:"Getting the menu program...":RNH,"HELLO"x STANDARD RANGED NUMERIC INPUT (HI-RES) ZB = MIN, ZT = MAX, ZC = C/R LEGAL (BOOLEAN)(1);:GCP,ZX,ZYZL((ZT)) CO,ZX,ZY:INP,(ZL,N,(ZC)),ZN$:ZN(ZN$)CE$(5):CF$(6):CL$(12):CN$(14):CO$(15):CP$(16):CQ$(17)I$'s0u STANDARD SPACE BAR ROUTINE )HI-RES):u(1):SPACE::y STANDARD ENDING ROUTINE (HI-RES)"yWIND:(12);(15):CO,0,89:"Do you want to try again? "(1);,y36000 I1:7210.I;.BOX,0,130,279,191:WIND:CO$:30000:].  DISPLAY THE NUMBER IN A(X).CO,(XP(X))7,YP(X):(A(X))" ". .* TEST A(A)....4CO$:CO,(XP(A))74,YP(A)14:A$;CN$.>.H DISPLAY MESSAGE.RT0ı(/\BOX,0,88:ZCZN$""ıaZNZBZNZTįCO,0,181:ZF1:"Enter a number between "ZB" and "ZT"."(3):37030ZFįCO,0,181:CEW:CO,ZX,ZY:Đ CZFįCO,0,181:CEW:CO,ZX,ZY:Đ CEW:CO,ZX,ZY:Đ C