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)
|