I think its wise to be careful how you approach this as although quicksort is 'quick' you could actually be using it inefficiently (or rather in a situation that isnt appropriate)

If your list is almost sorted then quicksort can be inefficient, (depending on how you choose your pivot, apparently choosing a random pivot can be a good idea)

Also this highlights how you should be careful when benchmarking any sorting algorithms as the order of the data before the sort greatly affects performance.

If its possible you might be better off storing your data already sorted.

How is the data generated?

If you have to sort then you might want to do some reading first :

http://www.cs.sunysb.edu/~algorith/lectures-good/node5.html

'the worst case time for Quicksort is worse than Heapsort or Mergesort.'

http://linux.wku.edu/~lamonml/algor/sort/quick.html

'the quick sort has horrible efficiency when operating on lists that are mostly sorted in either forward or reverse order - avoid it in those situations'

youre lucky though because this topic is very well covered :)


Martin
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to