Re: Bubblesort and Output

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Mike Williams" <Mike@xxxxxxxxxxxxxxxxx> wrote

> > I tried a bubblesort algorithim, but I'm sort of stuck. How do I
> > display the array after sorting it? How do I output it in sorted order?
>
> You're probably gonna get lets of replies telling you a Bubble Sort is just
> about the slowest sort you can do, and that there are alternative sorting
> methods that are very much faster.

I would advise you qualify that with the statement 'on data that may be found
in any order'.

On data that is already almost sorted, the bubble sort is one of the fastest
available to do the job.... It really depends on how often the data is to be
placed in sorted order. You are correct if its a one-time sort of jumbled
data, but if its a list that goes through iterations of adding/editing a few then
sort, adding/editing a few more then sort, etc.; the bubble sort could work well.
(fast, easy to code and understand, et. al)

LFS
.



Relevant Pages

  • Re: Returning Median Value
    ... That you are sorting singles does not make a great difference, the relative performance of the sorts in relation to each other remains the same and the absolute performance may be a little bit slower because comparing singles costs a little bit more than comparing longs. ... Max stack depth was set to 60 (which should be sufficient for up to 1 million elements to be sorted without resorting to insertion or heap sort in amlost all cases). ... Now if you can bear 4 ms for sorting 1000 items using bubble sort, ... Also the relative performance will change too, when the distribution of the items to be sorted changes. ...
    (microsoft.public.vb.general.discussion)
  • Re: A "valid" Bubble sort algorithm?
    ... > bubble sort algorithm given by program 6.4 in Algorithms in C by Robert ... The BubbleModLong sub below is from an unknown source and is ... > Dim i As Long ...
    (comp.programming)
  • Re: Possible F77 Code Improvement ??
    ... In fact, it is probably the fastest sort, or at ... of bubble sort, heapsort and perhaps others. ... I can see how constructing the heap in this case requires only O ...
    (comp.lang.fortran)
  • Re: comparing sorts
    ... I think the bubble/insertion sort counters are right. ... real seconds for bubble is 1.60000008E-02 ... This puts the input array in sorted order. ... a wrong algorithm if you ignore that knowledge of your data. ...
    (comp.lang.fortran)
  • Re: Bubblesort and Output
    ... How do I output it in sorted order? ... You're probably gonna get lets of replies telling you a Bubble Sort is just ... At that point (when the sort routine ...
    (microsoft.public.vb.general.discussion)