Paul Noble was kind enough to hunt through his archives and find
the technical data on a comb sort. The documentation shows that it
is a variation of a bubble sort that addresses the fundamental
problems with that design.
The result is a simple algorithm that in normal basic is getting
into the competitive range of sorting algorithms. In the data that
Paul found for me was a direct implementation in an old dialect
of basic called "True Basic" so with just a little fiddling, it
ported directly into PowerBASIC and ran correctly.
I have been testing on a worst case ordering of the data for a bubble
sort which is a reverse ordering of the sorted result, effectively
a descending order while sorting for an ascending order.
I set up a 1 million member array with the order in reverse to the sort
and it runs on my PIII 600 in about 2.5 seconds. I did not bother
to run the original bubble sort on that size because it probably would
not finish in my lifetime.
I set up a counter in the swap code and it performs about 2.8 million
swaps which is under 3 to 1 on the array member count which would have to
make it a very useful algorithm.
I have to nut out how to do the single floating point calculation
in a tidy manner but the rest of the algorithm should port to assembler
very well and since it is a small loop, the speed should come up very well.
Thsi is not a lot of use to programmers who are using PowerBASIC as Bob's
sorting code is very fast but in MASM where I do not have an efficient
sorting algorithm, this will be very useful.
I would like to thank not only Paul for digging this algo up but
Keith Waters for posting the fortran version. It seems that often
good ideas get lost or ignored as I found with the Boyer Moore algos
and if they are placed into current technology, the performance will
often surprise those who have not seen them before.
To contribute just a tinge of politics to the current debate on
language portability, I wonder if the current crop of nonsense like
java and C++ will port to a language 10 years down the track in under
5 minutes ?
Regards,
[email protected]
------------------
the technical data on a comb sort. The documentation shows that it
is a variation of a bubble sort that addresses the fundamental
problems with that design.
The result is a simple algorithm that in normal basic is getting
into the competitive range of sorting algorithms. In the data that
Paul found for me was a direct implementation in an old dialect
of basic called "True Basic" so with just a little fiddling, it
ported directly into PowerBASIC and ran correctly.
I have been testing on a worst case ordering of the data for a bubble
sort which is a reverse ordering of the sorted result, effectively
a descending order while sorting for an ascending order.
I set up a 1 million member array with the order in reverse to the sort
and it runs on my PIII 600 in about 2.5 seconds. I did not bother
to run the original bubble sort on that size because it probably would
not finish in my lifetime.
I set up a counter in the swap code and it performs about 2.8 million
swaps which is under 3 to 1 on the array member count which would have to
make it a very useful algorithm.
I have to nut out how to do the single floating point calculation
in a tidy manner but the rest of the algorithm should port to assembler
very well and since it is a small loop, the speed should come up very well.
Thsi is not a lot of use to programmers who are using PowerBASIC as Bob's
sorting code is very fast but in MASM where I do not have an efficient
sorting algorithm, this will be very useful.
I would like to thank not only Paul for digging this algo up but
Keith Waters for posting the fortran version. It seems that often
good ideas get lost or ignored as I found with the Boyer Moore algos
and if they are placed into current technology, the performance will
often surprise those who have not seen them before.
To contribute just a tinge of politics to the current debate on
language portability, I wonder if the current crop of nonsense like
java and C++ will port to a language 10 years down the track in under
5 minutes ?

Regards,
[email protected]
Code:
'########################################################################## SUB CombSort(Arr() as LONG,Size as LONG) LOCAL Gap as LONG LOCAL Switch as LONG LOCAL Hold as LONG LOCAL i as LONG LOCAL j as LONG Gap = Size Do Gap = Max&(Int(Gap/1.3),1) Switch = 0 For i = 1 To Size - Gap j = i + Gap If Arr(i) > Arr(j) Then Hold = Arr(i) Arr(i) = Arr(j) Arr(j) = Hold ! inc Switch End If Next i Loop Until Switch = 0 And Gap = 1 END SUB ' #########################################################################
Comment