QB / QB64 Discussion Forum      Other Subforums, Links and Downloads

 Return to Index  

Comparison of the Five Sorting Methods

September 26 2002 at 12:47 PM
Mac  (Premier Login iorr5t)

Response to Five (5) sorts comparison program


Five sorts are provided in the post above:

This is the sort that Solitaire published and named the "Shell" sort. I don't think it is, but there are conflicting definitions on the web.

Looking at
it seems like this matches QuickSort more than Shell.

Anyway, I tried it on 10,000 numbers and it ran in 18 seconds.

This is the sort that has been called the "Bubble" sort many times in the QBasic forum. I believe that "Selection" is the correct name.
Anyway, I tried it on 10,000 numbers and it ran in 518 seconds.

This is the correct "Bubble" sort. I didn't try it because it is always even worse than the Selection sort.

This is the correct "Shell" sort (I think).
Anyway, I tried it on 10,000 numbers and it ran in 24 seconds.

This is the correct version, I think.

Sorting an array of 10000 elements
S = Results when sorting an already Sorted file
U = Results when sorting an unsorted (random) file

  S      U    Sort Used
----- ------  ---------
0.16   1.92  Solitaire
56.08  77.88  Selection
0.00 249.09  Bubble
3.71  22.01  Shell
0.17   0.33  QuickSort

Conclusion: For large tables, the QuickSort is best and even if the table is previously sorted, you don't loose much time.

For short tables (less that 100 elements) I would use the Selection sort, as it is easiest to code.


This message has been edited by iorr5t on Nov 10, 2003 11:15 AM

 Respond to this message   

 Copyright © 1999-2018 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Newbies usually go to www.qbasic.com and click on The QBasic Forum
Forum regulars have their own ways, which include The QBasic Community Forums