From: Radu Grigore <radugrigore@gmail.com>
To: Jon Harrop <jon@jdh30.plus.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Set union
Date: Fri, 25 Feb 2005 12:56:58 +0200 [thread overview]
Message-ID: <7f8e92aa05022502566909d86@mail.gmail.com> (raw)
In-Reply-To: <200502240920.04902.jon@jdh30.plus.com>
On Thu, 24 Feb 2005 09:20:04 +0000, Jon Harrop <jon@jdh30.plus.com> wrote:
>
> Following my last post about the speed of set union in OCaml compared to
> C++/STL. What is the complexity of set union in OCaml in terms of the number
> of elements and the number of comparisons?
As no one gave an informed answer I'll risk a hand-waiving one.
When all elements of a set are bigger than all elements of the other
set the Set.union function seems to simply add the elements of the
small set to the bigger set one at a time. So the complexity looks
like O(m lg n) where m is the size of the smaller set. For other cases
the process is a bit more complex: take the root of the short tree,
split the large tree into smaller/larger elements based on that root,
compute union of "small" trees, "compute union of "large" trees",
merge them. If I'm not mistaken this is O(m lg n) too.
--
regards,
radu
http://rgrig.blogspot.com/
next prev parent reply other threads:[~2005-02-25 10:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-24 9:20 Jon Harrop
2005-02-25 10:56 ` Radu Grigore [this message]
2005-02-25 17:30 ` [Caml-list] " Jon Harrop
2005-02-25 17:48 ` Xavier Leroy
2005-02-25 19:47 ` [Caml-list] Complexity of Set.union Jon Harrop
2005-02-25 21:50 ` Radu Grigore
2005-02-25 21:52 ` Radu Grigore
2005-02-25 22:31 ` Radu Grigore
2005-02-25 22:36 ` Jon Harrop
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=7f8e92aa05022502566909d86@mail.gmail.com \
--to=radugrigore@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=jon@jdh30.plus.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