Re: Randomisation for ensuring nlogn complexity in quicksort

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Claudio Freire <klaussfreire(at)gmail(dot)com>
Cc: Atri Sharma <atri(dot)jiit(at)gmail(dot)com>, PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Randomisation for ensuring nlogn complexity in quicksort
Date: 2013-07-01 21:50:38
Message-ID: CA+TgmoZdPXWuO-Z+4zfFky=kG-7nOJiP_j6jGdsWzUnDMxMZzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 1, 2013 at 4:31 PM, Claudio Freire <klaussfreire(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robins Tharakan 2013-07-01 21:52:37 Re: Add more regression tests for CREATE OPERATOR
Previous Message Robert Haas 2013-07-01 21:46:51 Re: extensible external toast tuple support