[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-08-17 (11:37) |
From: | Xavier Leroy <Xavier.Leroy@i...> |
Subject: | Re: [Caml-list] map implementation question |
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