I am working on some binary-search-tree research and was surprised to find no mention of an algorithm to join two Scapegoat Trees. This is where two trees $L$ and $R$ are joined to create a single tree $T$, given that all values in $L$ are less than all values in $R$ and that all values are unique.
For this problem, the maximum height of a tree is $2\times\lfloor{\log_2(n)\rfloor}+1$ where $n$ is the total number of nodes in the tree and height is the number of nodes along the longest path (maximum depth + 1).
I have tried some ideas but none have passed the height invariant checks so far. Does anyone know of a resource that explores this idea, or can provide a reasonable approach for this problem? You can assume that every node is annotated with its size to make things easier.
Can this be done in $O(log(n))$ without exceeding the height bound?
One approach might be to use a simple BST join (remove max of $L$ or min of $R$ to be the root) and have the balance restored over the next few insertions, but that means the height upper-bound is not always guaranteed, especially after multiple joins.
2 * floor(log2(n)) + 1
$\endgroup$