From: Brian Hurt <bhurt@janestcapital.com>
To: caml-list@yquem.inria.fr
Subject: map implementation question
Date: Fri, 04 Aug 2006 16:08:36 -0400 [thread overview]
Message-ID: <44D3A944.3060907@janestcapital.com> (raw)
I was just looking at the map.ml implementation, and noticed that the
logic for when to do a rotation was:
> if hl > hr + 2 then begin
Isn't this supposed to be:
if hl >= hr + 2 then begin
? The latter will cause more rotations, but keep the tree more
balanced. The worst-case access of the >= version is log base 3/2,
while the > is log base 4/3, which means that the >= will be about 41%
(log(3/2)/log(4/3) ~ 1.41). Both are correct in that they return the
right answer and are still O(log(N)) performance, it's a question of
performance of looking up an element in the tree vr.s the cost of
inserting an element into the tree.
Was there a reason it was done this way, or is this a (minor) bug?
Brian
next reply other threads:[~2006-08-04 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-04 20:08 Brian Hurt [this message]
2006-08-17 11:37 ` [Caml-list] " Xavier Leroy
2006-08-17 16:25 ` j h woodyatt
2006-08-17 18:54 ` Shawn
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=44D3A944.3060907@janestcapital.com \
--to=bhurt@janestcapital.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