From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Brian Hurt <bhurt@janestcapital.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] map implementation question
Date: Thu, 17 Aug 2006 13:37:25 +0200 [thread overview]
Message-ID: <44E454F5.2040406@inria.fr> (raw)
In-Reply-To: <44D3A944.3060907@janestcapital.com>
Brian Hurt wrote:
> 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
No, it was a conscious decision to use height-balanced binary trees
with an height imbalance of at most 2, rather than at most 1 as in
standard AVL trees. As you note, log(N) access times are still
guaranteed, and it's a tradeoff between lookup time vs. rebalancing time.
Light experimentation suggested that imbalance <= 2 is globally more
efficient than imbalance <= 1. Didn't try with larger imbalance bounds.
This said, red-black trees would probably work faster anyway, but I'll
let the algorithm experts on this list comment.
- Xavier Leroy
next prev parent reply other threads:[~2006-08-17 11:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-04 20:08 Brian Hurt
2006-08-17 11:37 ` Xavier Leroy [this message]
2006-08-17 16:25 ` [Caml-list] " 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=44E454F5.2040406@inria.fr \
--to=xavier.leroy@inria.fr \
--cc=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