home *** CD-ROM | disk | FTP | other *** search
- 10000 rem sortieren mit baeumen
- 10010 rem
- 10020 rem heapsort
- 10030 rem
- 10040 lg=int(a/2)+1:rg=a
- 10050 if rg<=1 then 10190
- 10060 if lg<=1 then 10100
- 10070 rem aufbau des haufens
- 10080 lg=lg-1
- 10090 i=lg:goto 10140
- 10100 rem wegnehmen des maximums
- 10110 s$=a$(1)=a$(1)=a$(rg):a$(rg)=s$
- 10120 rg=rg-1
- 10130 i=1
- 10140 x$=a$(i)
- 10150 p=0:rem flag fuer nicht gefunden
- 10160 if 2*i<=rg and p=0 then 10200
- 10170 a$(i)=x$
- 10180 gosub 3000: goto 10050
- 10190 goto 10300: rem ende
- 10200 rem feldvariable a$(i) einordnen
- 10210 j=2*i
- 10220 if j<rg then if a$(j)<a$(j+1)then j=j+1
- 10230 if x$>=a$(j) then 10260
- 10240 a$(i)=a$(j)
- 10250 i=j:goto 10160
- 10260 p=1:rem flag fuer platz gefunden
- 10270 goto 10160
- 10280 :
- 10290 :
- 10300 rem ende
-