TIP: Click on subject to list as thread! ANSI
echo: locuser
to: Peter Nielsen
from: Keith Richardson
date: 1995-08-15 14:47:59
subject: Sort of sorting...

On (15 Aug 95) Peter Nielsen wrote to Bob Lawrence...



 PN> Moved from AVTECH to here for quick transmission :-)



 PN> Hi Bob



 PN> Here is something to think about.      A Double Bubble sort !!



 PN> It is in 2 sections that between them more than doubles the speed of a

 PN> normal bubble sort.



i did something like this when i did a fortran course once, and we had

to write a bubble sort as an exercise. it gives a dramatic increase in

speed.



 PN> If the next element is greater than this one, then swap the elements and

 PN> set the flag



 PN> 8130 NEXT XS     do next loop step



 PN> 8135 IF CS=0 GOTO 8197     If no swap occured then sort is complete.



you can also get a further increase in speed if, instead of just using a

simple binary flag, you save the index of the current swap. you then use

this as the loop limit in the next pass as anything in the list beyond

the last swap must already be in order.



of course its all rather futile, as the only good thing about a bubble

sort is that it is easy to understand. it will never be fast no matter

what you do, unless you are sorting very short lists where the set up

time for the more complex and efficient sort techniques become

significant.



                        Keith



... The end of the world is nigh - please log off.



--- PPoint 1.92


* Origin: Malfunction Junction (3:711/934.6)
SEEN-BY: 711/934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.