home *** CD-ROM | disk | FTP | other *** search
- Path: combo.ganesha.com!peterk
- From: peterk@combo.ganesha.com (Dr. Peter Kittel)
- Subject: Re: Sorting a list
- Newsgroups: comp.sys.amiga.programmer
- Reply-To: peterk@combo.ganesha.com
- References: <272.6650T63T1340@sn.no> <ZZNYYD.96Mar21121908@diku.dk> <xUqu7MD1A7alz7@0dietmar.tomate.tng.oche.de>
- Message-ID: <peterk.0m19@combo.ganesha.com>
- Date: 27 Mar 96 00:22:03 MEZ
- Organization: Private Site
-
- In article <xUqu7MD1A7alz7@0dietmar.tomate.tng.oche.de> DIETMAR@TOMATE.TNG.OCHE.DE (Dietmar Eilert) writes:
- >
- >You could use a simple modification of bubble sort to boost performance to
- >the speed of QuickSort: use a dynamic interval instead of comparing
- >neighbours only. In the first pass, you would compare element <a> to
- >element <a + distance> and swap them if the order is wrong. Distance is
- >reduced after processing all elements. To be continued until the distance
- >is <1> (standard bubble sort) and the order is correct.
- >
- >First pass:
- >
- > distance = 3 * (elements - 1) / 4
- >
- > if (distance == 0)
- > distance = 1;
- >
- >Next pass:
- >
- > if (distance = 3 * distance / 4)
- > ready = FALSE;
-
- Ah, one of my pet issues. This sounds very similar to the CombSort
- algorithm (Byte 4/1991, p. 315, S. Lacey, R. Box, developed on an Amiga!).
- They use an initial distance of (elements) and divide this number for
- every scan by 1.3, but of course don't go below 1. As an optimization,
- distances of 9 or 10 are avoided and replaced by 11. This way they also
- nearly reach QuickSort performance. Simply amazing.
-
- --
- Best Regards, Dr. Peter Kittel // Visit http://www.amiga.de
- Private Site in Frankfurt, Germany \X/ Email to: peterk@combo.ganesha.com
- Employed at AMIGA Technologies GmbH in Bensheim, Germany
-