QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 Return to Index  

Some sorting theory

March 18 2004 at 1:59 AM
  (no login)


Response to Shell Sort, Bubble Sort, Sorting in general

Sorting is, essentially, putting a set of values from a random order into ascending or descending order of size, by performing many swaps of two values. The problem is finding a way to do it that takes as few swaps as possible but is also not bogged down by the processing time.

It would be a lot easier if the values were all integers from 1 to X, in which case we know what value the n'th element will have. (I.e. we know that SortArray(n) will be n)
In practice, we do not know what will be at the n'th element. Selection sorts essentially determine this for each element from 1 to X-1. (X is obviously the remaining one)
The Bubble Sort brings all out-of-place elements one position up until it's sorted.
The QuickSort is very fast because it divides and divides and divides and divides and then conquers!!
Simple and effective.

 
 Respond to this message   

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