A little "bubble" variation that does the same... This way is easier to remember for me
for(int i = 0; i < n - 1; i++)
{
for(int j = i; j < n ; j++)
{
if(array > array[j])
// assume a function that switches two variables...
swap(array, array[j]);<br>}<br>} <br><br><br>EDU<br> </i>
What the heck is a bubble sort?
The bubble sort is the easiest to implement and it is also the smallest to code. In college we had a program to write in (VMS) asm - the objective was to make it as small as possible and input/sort/output 10 integers. Everyone used a bubble sort because it takes ~6lines of asm.
The insertion sort is faster than a quick or merge sort on nearly sorted data - much faster if you know the list is already sorted.
And the quick sort ain''t so quick when it''s done with recursive functions - for the same reason recursive FFTs are hideously slow.
Magmai Kai Holmlor
- The disgruntled & disillusioned
The insertion sort is faster than a quick or merge sort on nearly sorted data - much faster if you know the list is already sorted.
And the quick sort ain''t so quick when it''s done with recursive functions - for the same reason recursive FFTs are hideously slow.
Magmai Kai Holmlor
- The disgruntled & disillusioned
The fast quick sort appears to quicksort the data until it''s in an almost-sorted state, then switches to an insertion sort. Seems quite effecient to me.
If you really want to get a good idea of how long it all takes, use a profiler.
If you really want to get a good idea of how long it all takes, use a profiler.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement