Re: Mergesort algorithm for linked lists
- From: "Stephen Howe" <sjhoweATdialDOTpipexDOTcom>
- Date: Tue, 30 Jan 2007 15:21:42 -0000
Of course, it is a trivial modification to search for partitions that
are either ascending or descending, and tag them as such.
With this simple variant, the reverse ordered set is also fully sorted
after n operations (we just peel the data from the far end instead of
the near end when accessing a reversed partition).
True. But seeing how mergesort is one of the only N * log N sorts that can
be stable, it is desireable to preserve stability even if reversed. And that
means special treatment for equal elements. It can be done.
And note there is still a worse case: An alternating zig-zag pattern that
ascends and descends.
By worse case I mean it is still N * log N, but the sort will have the most
amount of work to do and the greatest amount of auxilary space will be
consumed.
Stephen Howe
.
- References:
- Re: Mergesort algorithm for linked lists
- From: pete
- Re: Mergesort algorithm for linked lists
- From: Googmeister
- Re: Mergesort algorithm for linked lists
- From: pete
- Re: Mergesort algorithm for linked lists
- From: Stephen Howe
- Re: Mergesort algorithm for linked lists
- From: user923005
- Re: Mergesort algorithm for linked lists
- Prev by Date: Re: Mergesort algorithm for linked lists
- Next by Date: help with automatic code generation
- Previous by thread: Re: Mergesort algorithm for linked lists
- Next by thread: Re: Mergesort algorithm for linked lists
- Index(es):
Relevant Pages
|