home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PARADIS1
/
COMBSORT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-02-13
|
1KB
|
68 lines
(5143) Sun 9 Feb 92 15:56
By: Jud Mccranie
To: David G. Edwards
Re: Insert Sort
St:
---------------------------------------------------------------------------
DG> Would you mind posting an example of the Combination sort?
DG> Where'd you find it?
const size = 500;
var list : array[ 1 .. size] of real;
procedure CombSort( size : integer);
{ comb (combination) sort, Stephen Lacy and Richard Box,
Byte, April 1991, 315-320. }
var i, j, gap : integer;
NoSwitches : boolean;
temp : real;
begin
gap := size;
repeat
if gap < 3276
then gap := (10 * gap) div 13
else gap := trunc( 0.78923 * gap);
if gap <= 0
then gap := 1
else if (gap = 9) or (gap = 10) then gap := 11;
NoSwitches := true;
for i := 1 to size - gap do
begin
j := i + gap;
if list[ i] > list[ j] then
begin
temp := list[ i];
list[ i] := list[ j];
list[ j] := temp;
NoSwitches := false
end
end
until NoSwitches and (gap <= 1)
end; { --- comb sort --- }
I hope I'm not violating a copyright. I cleaned up and optimized their
code a little bit. Pretty simple, like a cross between bubble and
shell. Runs about as fast as shell, which is generally fast enough.
--- Via Silver Xpress V2.28
* Origin: The Bad Lands BBS 650+Megs (912)247-6977 (1:370/520)
@PATH: 370/520 510 20 151/1003 13/13 396/1 170/400 512/0 1007