Which sort show the best average behavior?

Answer Posted / mr. x

Lots of ppl asked, nobody had a clue.

The best sorting algorithm on average depends on the data to
be sorted. If the data is more or less well evenly
distributed, the best sorting algorithm is Radixsort or
Bucketsort, with average and worst cases of O(n).

Next are a class of very complex algorithms (impractical)
which are O(n log log n).

Next are the O(n log n) algorithms. Mergesort and Heapsort
both show average and worst case complexities of O(n log n).
Quicksort is to be avoided as the plague!!!!! It has
non-deterministic complexity and has a worst-case behaviour
of O(n^2). No wonder why there are so many crappy
applications out there.

Then Shellsort is pretty good for small-to-medium lists, as
long as you choose the best gaps (around O(n log^2 n)).
Otherwise it can perform O(n^4/3) or even O(n^2)!.

All other sorts are to be avoided, except for very specific
cases or when simplicity is far more important than code
velocity.

Is This Answer Correct ?    10 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What the principle of quick sort and its complexity?

735


What is difference between array and arraylist?

678


What is best time complexity?

617


What are the advantages and disadvantages of linked list?

586


What are data structures in programming?

707


What is difference between concurrenthashmap and hashtable?

621


What is the time complexity of selection sort?

627


What are scalar values?

642


What is different between array and list?

695


What are the different types of linked list?

628


What do you mean by data and data structure?

707


Explain the priority queue?

715


What is a matrix? Explain its uses with an example

761


What is the difference between file structure and storage structure?

714


What is numeric array?

591