From: "Dário Abdulrehman" <drehman31@gmail.com>
To: "Bruno De Fraine" <Bruno.De.Fraine@vub.ac.be>
Cc: "Jon Harrop" <jon@ffconsultancy.com>, caml-list@inria.fr
Subject: Re: [Caml-list] kth smallest element
Date: Tue, 16 Jan 2007 11:25:59 +0000 [thread overview]
Message-ID: <6aeedf580701160325tdcf56cbvb2b1cef00998148c@mail.gmail.com> (raw)
In-Reply-To: <64962DD2-F738-4812-B6BA-29ED5CF1AD75@vub.ac.be>
[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]
This is not a trivial problem as can be seen here:
http://en.wikipedia.org/wiki/Selection_algorithm
http://www.derekroconnor.net/home/MMS406/Sorting.pdf
Bruno, I think the modified quicksort explained in the PDF is more efficient
than using a min-heap.
On 1/16/07, Bruno De Fraine <Bruno.De.Fraine@vub.ac.be> wrote:
>
> On 15 Jan 2007, at 20:56, Jon Harrop wrote:
> > Anyone got code for the kth smallest element in a list that I can
> > borrow?
>
> I have code for a set that can be limited to a certain size. While
> you add a potentially very large number of elements, the set will
> retain the 30 largest elements it has seen up to that point (given
> that the set was initialized with bound 30). You could modify the
> code to keep track of the smallest elements instead.
>
> Regards,
> Bruno
>
>
>
>
>
> --
> Bruno De Fraine
> Vrije Universiteit Brussel
> Faculty of Applied Sciences, INFO - SSEL
> Room 4K208, Pleinlaan 2, B-1050 Brussels
> tel: +32 (0)2 629 29 75
> fax: +32 (0)2 629 28 70
> e-mail: Bruno.De.Fraine@vub.ac.be
>
>
>
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 2127 bytes --]
prev parent reply other threads:[~2007-01-16 11:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-15 19:56 Jon Harrop
2007-01-16 8:32 ` [Caml-list] " Bruno De Fraine
2007-01-16 11:25 ` Dário Abdulrehman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6aeedf580701160325tdcf56cbvb2b1cef00998148c@mail.gmail.com \
--to=drehman31@gmail.com \
--cc=Bruno.De.Fraine@vub.ac.be \
--cc=caml-list@inria.fr \
--cc=jon@ffconsultancy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox