Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

How to get the index of an array element?

1005


How will you sort the elements of array in descending order?

901


Define heap?

1002


What is nsmutablearray?

777


Why quicksort is called quick?

861


Can treemap key null?

984


Can arraylist have null values?

808


What is binary tree give example?

861


Does list allow null values?

876


What are the different types of data type?

879


Why it is important to have aligned addresses? What is the exception generated when there is a misaligned address?

841


What is difference between data type and variable?

761


Explain the common uses of tree database.

869


How many passes are required in bubble sort?

767


What do you mean by data and data structure?

919