From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Andrew Herron <andrew.herron@gmail.com>
Cc: Damien Guichard <alphablock@orange.fr>, Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Why AVL-tree?
Date: Mon, 2 Jun 2014 17:06:05 +0200 [thread overview]
Message-ID: <CAPFanBGWGDw9ofH8_643CMg9PgX7xkSD8hWROnh5KpSmm4wgcw@mail.gmail.com> (raw)
In-Reply-To: <1401716071976.85ecb8da@Nodemailer>
Note that OCaml's balanced trees are not exactly what is usually
called AVL, as the imbalance between different branches can be at most
2 (+1 on one side and -1 on the other) instead of just 1 as the
traditional definition assumes.
On Mon, Jun 2, 2014 at 3:34 PM, Andrew Herron <andrew.herron@gmail.com> wrote:
> Wikipedia has some notes on the difference:
>
> http://en.wikipedia.org/wiki/AVL_tree
>
> AVL has faster lookup, so maybe they decided to optimise for that.
>
> It's different to some other languages I've seen, but then so is their
> decision to not use a tail recursive List.map. Each to their own, it's not
> hard to implement the alternative :)
>
>
> On Mon, Jun 2, 2014 at 11:21 PM, Damien Guichard <alphablock@orange.fr>
> wrote:
>>
>>
>> Red-black tree would spare a machine word per node, because a red-black
>> tree doesn't need depth information.
>> Hence the reason is either historical or a space/speed trade-off
>> (comparing two depths may be faster than pattern matching).
>>
>> Regards,
>>
>> damien guichard
>>
>> Hi, list,
>>
>> Just from the curiosity, why balanced binary trees used in Set and Map are
>> AVL-trees, not their alternative, say, red-black trees? Is there a deep
>> reason for it, or just a historical one?
>>
>> Best,
>> --
>> Yoriyuki Yamagata
>> http://yoriyuki.info/
>>
>>
>
next prev parent reply other threads:[~2014-06-02 15:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-02 13:21 Damien Guichard
2014-06-02 13:34 ` Andrew Herron
2014-06-02 15:06 ` Gabriel Scherer [this message]
2014-06-03 12:48 ` Yaron Minsky
2014-06-03 13:12 ` Gabriel Scherer
2014-06-03 13:37 ` Yaron Minsky
2014-06-03 13:41 ` Yoriyuki Yamagata
2014-06-02 16:57 ` Xavier Leroy
2014-06-02 21:16 ` Andrew Herron
2014-06-10 18:19 ` jonikelee
2014-06-10 18:51 ` Florian Hars
2014-06-10 19:52 ` Jonathan
2014-06-15 4:51 ` Lukasz Stafiniak
2014-06-15 14:01 ` Jonathan
2014-08-03 21:25 ` Diego Olivier Fernandez Pons
-- strict thread matches above, loose matches on Subject: below --
2014-06-02 18:23 Damien Guichard
2014-06-02 11:48 Yoriyuki Yamagata
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=CAPFanBGWGDw9ofH8_643CMg9PgX7xkSD8hWROnh5KpSmm4wgcw@mail.gmail.com \
--to=gabriel.scherer@gmail.com \
--cc=alphablock@orange.fr \
--cc=andrew.herron@gmail.com \
--cc=caml-list@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