sorting algorithms
- dELtaluca
-
dELtaluca
- Member since: Apr. 16, 2004
- Offline.
-
- Forum Stats
- Member
- Level 20
- Blank Slate
what is the best type of algorithm for sorting a set of single values where the size of the list can be anywhere from 2 to 200?
atm im using a cocktail search (the bidirectinoal bubble search)
the data is stored in a simple array like
float c [20];
but im not sure if the cocktail search is fastest for this
- henke37
-
henke37
- Member since: Sep. 10, 2004
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
Depends on the task, is the data very random or nearly ordered?
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.
- dELtaluca
-
dELtaluca
- Member since: Apr. 16, 2004
- Offline.
-
- Forum Stats
- Member
- Level 20
- Blank Slate
At 11/5/06 10:02 AM, henke37 wrote: Depends on the task, is the data very random or nearly ordered?
it will usually be very random.
- StarCleaver
-
StarCleaver
- Member since: Jan. 3, 2003
- Offline.
-
- Forum Stats
- Member
- Level 29
- Blank Slate
You could use any number of sorts, because the set of data you are sorting is not very large or very complex. You say you have "set of single values" which I'm going to take as you have an array of integers or floating point numbers. In your case I would use radix sort. It is very stable and doesn't have to compare the numbers to each other.
You can also use many other sorts, just don't use cocktail sort or bubble sort, they are easy to implement, but shitty.
I could surely die
If I only had some pie
Club-a-Club Club, son
- StarCleaver
-
StarCleaver
- Member since: Jan. 3, 2003
- Offline.
-
- Forum Stats
- Member
- Level 29
- Blank Slate
http://en.wikipedia.org/wiki/Sorting_algorith m#Radix_sort
Always helpful.
http://en.wikipedia.org/wiki/Sorting_algorith m#Radix_sort
This is just neat. Check out how shitty bubble sort is compared to the others and you'll know why you shouldn't use it. Just click on the pictures to start the sorts.
I could surely die
If I only had some pie
Club-a-Club Club, son

