From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] filter on map
Date: Thu, 7 Jun 2007 10:11:18 +0100 [thread overview]
Message-ID: <200706071011.18674.jon@ffconsultancy.com> (raw)
In-Reply-To: <4667C188.1060408@univ-savoie.fr>
On Thursday 07 June 2007 09:27:52 Christophe Raffalli wrote:
> But I am now wondering: this is O(n ln n), isn't there an O(n)
> implementation (or just a faster implementation). This code insert the keys
> in increasing order which is the worst case for balancing ? Just using a
> "random_fold" should make things better ...
If you can cull branches of search tree whilst filtering then you can make
this <O(n) by pulling your function inside "Map". Even if you can't, I think
you can still make it O(n) instead of O(n log n) by adding a Map.of_seq
function that builds a map from an association list in O(n).
I would recommend putting the Set.union function into Map and writing this in
terms of that.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e
next prev parent reply other threads:[~2007-06-07 9:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-07 8:27 Christophe Raffalli
2007-06-07 9:11 ` Jon Harrop [this message]
2007-06-07 13:16 ` [Caml-list] " Brian Hurt
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=200706071011.18674.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.inria.fr \
/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;
as well as URLs for NNTP newsgroup(s).