Be a Supporter!

sorting algorithms

  • 417 Views
  • 4 Replies
New Topic Respond to this Topic
dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
sorting algorithms 2006-11-05 04:21:12 Reply

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


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature
henke37
henke37
  • Member since: Sep. 10, 2004
  • Offline.
Forum Stats
Member
Level 30
Blank Slate
Response to sorting algorithms 2006-11-05 10:02:48 Reply

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
Response to sorting algorithms 2006-11-05 10:53:23 Reply

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.


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature
StarCleaver
StarCleaver
  • Member since: Jan. 3, 2003
  • Offline.
Forum Stats
Member
Level 29
Blank Slate
Response to sorting algorithms 2006-11-05 12:33:34 Reply

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

BBS Signature
StarCleaver
StarCleaver
  • Member since: Jan. 3, 2003
  • Offline.
Forum Stats
Member
Level 29
Blank Slate
Response to sorting algorithms 2006-11-05 12:37:08 Reply

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

BBS Signature