Re: fast stable sort
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Thu, 13 Nov 2008 05:19:53 -0500
subramanian100in@xxxxxxxxx, India wrote:
I am practicing C programming at home. The C standard library function
qsort() as per the C standard document, need not be stable. So I want
to know the following.
Which sorting methods are stable ?
Among the stable sorting methods, which method is both stable and
fastest ?
For small arrays, insertion sort is usually fastest.
For large arrays, merge sort is usually fastest,
but it is not an in place sorting algorithm.
While those algorithms are inherently stable,
you have to be careful when you code them
because they can also be coded as nonstable algorithms.
There is an example of a nonstable mergesort function
named "mergeSort", at:
http://www.azillionmonkeys.com/qed/sorttest.c
The function mergeSort, is not stable because
it uses a nonstable function named insertSort
to sort the small partitions.
insertSort uses a nonstable simple selection sort algorithm.
--
pete
.
- Follow-Ups:
- Re: fast stable sort
- From: CBFalconer
- Re: fast stable sort
- From: Richard Harter
- Re: fast stable sort
- References:
- fast stable sort
- From: subramanian100in@xxxxxxxxx, India
- fast stable sort
- Prev by Date: Re: Red-black trees?
- Next by Date: Re: fast stable sort
- Previous by thread: Re: fast stable sort
- Next by thread: Re: fast stable sort
- Index(es):
Relevant Pages
|