Re: Randomisation for ensuring nlogn complexity in quicksort - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Randomisation for ensuring nlogn complexity in quicksort
Date
Msg-id CA+TgmoZdPXWuO-Z+4zfFky=kG-7nOJiP_j6jGdsWzUnDMxMZzA@mail.gmail.com
Whole thread Raw
In response to Re: Randomisation for ensuring nlogn complexity in quicksort  (Claudio Freire <klaussfreire@gmail.com>)
List pgsql-hackers
On Mon, Jul 1, 2013 at 4:31 PM, Claudio Freire <klaussfreire@gmail.com> wrote:
> What?
>
> A median of medians algorithm will guarantee floor(N/2) elements on
> the smaller. That's the definition of median.
>
> Note that I'm referring to picking the actual median of all tuples,
> not just a sample. That's slow, but it guarantees O(n log n).

Ah, OK.  Well, yes, that would guarantee O(n lg n).  But, as you say,
it would be slow.  :-)

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: extensible external toast tuple support
Next
From: Robins Tharakan
Date:
Subject: Re: Add more regression tests for CREATE OPERATOR