rpds icon indicating copy to clipboard operation
rpds copied to clipboard

Merging two red-black trees

Open dotnwat opened this issue 3 months ago • 4 comments

I'm interested in being able to efficiently merge two red-black trees, specifically optimizing for the case in which trees share most structure. For example:

// first tree
tree = red_black_tree();
tree = tree.insert(1);
tree = tree.insert(2);

// second tree, forked from the first
other = tree.insert(3);
other = tree.insert(4);

// fold them back together
tree = tree.merge(other);

I'm wondering if you have any takes on this and/or suggestions about how to approach the problem. Thanks!

dotnwat avatar Oct 03 '25 14:10 dotnwat