Re: Mergesort algorithm for linked lists
- From: "Stephen Howe" <sjhoweATdialDOTpipexDOTcom>
- Date: Mon, 29 Jan 2007 23:24:18 -0000
He's talking about *natural* mergesort. Natural mergesorting
a sorted linked list of n elements takes n-1 comparisons.
I am unfamiliar with "*natural* mergesort".
Natural mergesort is where you take advantage of any builtin order of the
list.
Effectively you split the list into a series of runs as presented in the
initial data.
So if it is already sorted, then the "*natural* mergesort" will generate 1
run of N elements, therefore it is O(N)
But if it in reverse-order, any comparison is such that each element will be
in its own run of length 1.
It is still O(N * log N) to sort as you merge adjacent runs - but you will
do the maximum amount of merging.
Stephen Howe
.
- Follow-Ups:
- Re: Mergesort algorithm for linked lists
- From: user923005
- Re: Mergesort algorithm for linked lists
- References:
- Re: Mergesort algorithm for linked lists
- From: Stephen Howe
- 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
- Prev by Date: graphics R&D positions, London, England
- Next by Date: Re: Mergesort algorithm for linked lists
- Previous by thread: Re: Mergesort algorithm for linked lists
- Next by thread: Re: Mergesort algorithm for linked lists
- Index(es):