in reply to Re: Re: bubble sort in perl
in thread bubble sort in perl
It's better than some, but you'd really want to do a selection or insertion sort to add your new elements, I think, depending on your data structure.
The problem is that bubble sort only ever moves an element 1 spot. So if you add an element that would normally go into position 1 of a 1000-item list at the end of the pre-sorted list, you're looking at 1000 iterations over the whole list to "bump" it up into position 1. Ouch...
--
Mike
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:(4) bubble sort in perl
by particle (Vicar) on Mar 24, 2002 at 14:29 UTC | |
by RMGir (Prior) on Mar 24, 2002 at 14:37 UTC |