Open treeowl opened 8 years ago
Never mind the two-element insertion for union. It turns out that balance
variants are sufficient to implement insert2
, but union
using that is slow. I'm guessing this could be a branch prediction issue, but I'm not really sure.
We have
Several places we call this, we know that only one subtree could possibly be heavy. So we should add
and
linkR
similarly.So I don't forget: these should be useful for implementing
insert2
andinsert2R
for two-elementunion
special cases. If both elements go left/right, we only need to check balance one way; if one goes left and the other right, we don't need to check balance at all.