TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: BRIAN WOOD
from: THOMAS MAEDER
date: 1998-01-16 07:52:00
subject: sort algorithm

BW> That's a good one, I didn't think it would work, but it does.  Seems
If you think that bubble sort is a good sorting algorithm, I  have  to
object.
BW> go through the entire array, moving higher values to the left, setti
BW> test=0 if there was a sort performed, so the while loop gets perform
BW> again on the entire array.  Thanks for the loop!
The  number  of times two elements are compared is proportional to the
square of the number of elements in the average case. Other algorithms
are much faster.
On  the  other  hand,  the  trick  with  the  test variable gives this
implementation a  very  good  performance  if  the  array  is  already
(almost)  sorted  (proportional to the number of elements). But that's
not very interesting usually.
Thomas
---
 þ MM 1.0 #0113 þ Remember - you're unique, just like everybody else.
---------------
* Origin: McMeier & Son BBS (2:301/138)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.