TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: GEORGE WHITE
from: TOM TORFS
date: 1998-04-15 22:42:00
subject: Bubble Becomes Zeppelin

George White wrote in a message to Tom Torfs:
TT>TT>for (i1=0; i1TT>   for (i2=i1; i2TT>      if (elem[i1]>elem[i2])
 GW> As there is no need to compare an element with itself you can
 GW> remove a redundant check from the start of the inner loop and a
 GW> redundant outer loop by changing the loop parameters to:
 GW> for (i1=0; i1    for (i2=i1+1; i2       if (elem[i1]>elem[i2])
Yes, that's how I had it originally. However, as I only use this for arrays 
of, for example, 10 or 20 elements, I don't even bother doing that sort of 
optimization. I use qsort() for anything larger, but I really can't be 
bothered to do that for such small arrays.
greetings,
Tom
tomtorfs@village.uunet.be
--- timEd/2 1.10+
---------------
* Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516)

SOURCE: echomail via exec-pc

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™.