e***r 发帖数: 68 | 2 According to :
Joining of two BSTs at Page552:
Program 12.23 Joining of two BSTs
If either BST is empty, the other is the result. Otherwise, we combine the
two BSTs by (arbitrarily) choosing the root of the first as the root, root
inserting that root into the second, then (recursively) combining the pair
of left subtrees and the pair of right subtrees.
private Node joinR(Node a, Node b)
{ if (b == null) return a;
if (a == null) return b;
insertT(b, a.item); //把a插入到b |
|