Re: Mergesort algorithm for linked lists
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Sun, 28 Jan 2007 04:46:34 GMT
Stephen Howe wrote:
The worst case for natural mergesort is
if the data is in reverse order to
start with. There are no "runs" then.
That's completely wrong for stable mergesorting of linked lists
and mostly wrong for stable mergesorting of arrays.
Mergesorting a reverse ordered list requires the minimum
number of comparisons for a given number of elements;
that is the same number of comparisons
required for stable mergesorting of
an already sorted list of same size.
That is to say that the work involved in a
stable mergesorting of a reverse ordered linked list,
is the same as the amount of work involved
in a stable mergesorting of a foward ordered linked list
For a stable mergesorting of an array,
the reverse ordered array
requires the minimum number of comparisons
but the maximum amount of data movement,
which is not the same as a worst case.
--
pete
.
- Follow-Ups:
- Re: Mergesort algorithm for linked lists
- From: Stephen Howe
- Re: Mergesort algorithm for linked lists
- From: Googmeister
- Re: Mergesort algorithm for linked lists
- References:
- Re: Mergesort algorithm for linked lists
- From: Stephen Howe
- Re: Mergesort algorithm for linked lists
- Prev by Date: just starting
- Next by Date: Re: just starting
- Previous by thread: Re: Mergesort algorithm for linked lists
- Next by thread: Re: Mergesort algorithm for linked lists
- Index(es):