I agree with Dilip. It depends upon what type of input you have at hand. - Suppose you have an array having a million elements, where the elements are in the range 1-3, counting sort would be perfect. - However, if the range is from -10^18 to +10^18, counting sort, which requires O(R) memory, where R is the range of the elements, would be laughable. Here quick-sort or merge-sort would be better.
Again, quick-sort is good for randomized inputs, such that the pivot lies roughly in the middle of every sub-array. For certain inputs, the performance of quick-sort degrades to O(N^2). For this reason, the default implementation of sort function in STL, uses 'Intro-Sort' [0] which is a combination of quick-sort and heap-sort (switches between the two depending upon the input) [0] http://en.wikipedia.org/wiki/Introsort On Fri, Aug 5, 2011 at 6:54 AM, dilip makwana <[email protected]> wrote: > But beware all linear sort algo have some prior constraints (such as range > of input is predefined or such ...) > So choose one properly .... > > On 4 August 2011 23:12, Samba Ganapavarapu <[email protected]> wrote: >> >> Merget Sort sorts O(n log n) time, >> Counting sort, Radix sort sorts in O (n) time... >> >> >> On Thu, Aug 4, 2011 at 1:40 PM, Rohit jalan <[email protected]> wrote: >>> >>> Merge Sort >>> >>> On Thu, Aug 4, 2011 at 11:09 PM, parag khanna <[email protected]> >>> wrote: >>>> >>>> Which is fastest sorting method? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>> >>> >>> >>> -- >>> Regards : >>> ROHIT JALAN >>> B.E. Graduate, >>> Computer Science Department, >>> RVCE, Bangalore >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. > > > > -- > Dilip Makwana > VJTI > BTech Computers Engineering > 2009-2013 > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
