[Coco] 6809 example
Robert Gault
robert.gault at worldnet.att.net
Sun Jan 18 00:06:02 EST 2004
Roger Taylor wrote:
> At 01:50 PM 1/17/2004 -0500, you wrote:
>
>> Note that even though the code is more complex, the speed is much much
>> faster than the bubble sort. By implication this also means that if
>> speed is your primary concern in picking a language, think again! The
>> algorithm and quality of coding can be more important than the language.
>>
><snip>
>> 30 D=INT(2^INT(LOG(512)/LOG(2))-1)
><snip>
>
>
>
> That looks like more than a handful for a beginner, especially the LOG
> functions. I think a Hello World to stdout would be a very good 1st
> example.
>
>
> ----------
> Roger Taylor
>
>
>
>
That's true, but for the specific lesson shown the natural logs can be
pre-calculated and the value of D, 255, used as a constant. The value
should be based on N, where N is the number of items to be sorted. So
strictly speaking the equation is
D=INT(2^(LN(N)/LN(2)) -1 and N = 512 for the low res Coco screen.
The algorithm comes from an article by Terry Barron in Byte, May 1983.
It is also interesting to note that the author considers this only a
medium efficiency sort.
More information about the Coco
mailing list